Shaykh Ibn Baz was asked: If a person travels to Jeddah, for example, is he allowed to shorten his prayers or does he have to pray with the congregation in the mosque? 

He replied: 

If the traveler is still in route, it does not matter, but if he has reached his destination, then he should not pray on his own, rather he has to pray with the people and offer the prayer in full. But if he is still on the road and is alone and the time for prayer comes, there is nothing wrong with him praying on his own and shortening the prayers whilst traveling, making the four-rak`ah prayers two rak’ahs.

Shaykh Ibn ‘Uthaymeen, a prominent Muslim scholar, was asked: when and how should a traveler pray? 

he replied: 

the traveler may pray two rak’ahs from when he leaves his city or town, until he returns to it, because ‘A’ishah (may Allah be pleased with her) said: “When the prayer was first enjoined it was two rak’ahs, then the prayer of the traveller remained like that but the prayer of one who is not travelling was increased to four.” Narrated by al-Bukhari and Muslim

and Anas (may Allah be pleased with him) said: “We went out with the Prophet (peace and blessings be upon him) from Madinah to Makkah, and we prayed two rak’ahs each time, until we came back to Madinah. Narrated by al-Bukhari and Muslim

But if a traveler prays with an imam he should pray four rak`ahs, whether he catches up with the prayer from the beginning or he misses part of it, because the general meaning of the Prophet’s words: “When you hear the iqamah (call to perform prayer), then walk to the prayer, and you should be tranquil and dignified, and not rush. Whatever you catch up with, pray, and whatever you miss, complete it.” Narrated by al-Bukhari and Muslim

the general meaning of the phrase “Whatever you catch up with, pray, and whatever you miss, complete it.” includes travelers who pray behind an imam who is offering a four-rak`ah prayer, and others. 

The obligation to pray in congregation is not waived for the traveler, because Allah has enjoined offering prayer in congregation even in the case of fighting.
allah says: 
When you (O Messenger Muhammad) are among them, and lead them in As-Salaah (the prayer), let one party of them stand up [in Salaah (prayer)] with you taking their arms with them; when they finish their prostrations, let them take their positions in the rear and let the other party come up which have not yet prayed, and let them pray with you…” [An-Nisa’ 4:102] 

Based on this, if the traveler is in a city or town other than his own, he has to attend prayers in congregation in the mosque if he hears the call to prayer, unless he is far away or fears that he may miss meeting up with his traveling companions, because of the general meaning of the evidence which indicates that the one who hears the adhaan or iqaamah is obliged to pray in congregation.