When Is It Compulsory to Pray at the Mosque?
Question

I know it is compulsory for men to pray  their 5 daily prayers at the Masjid. But when a person lives a distance away from the Masjid at what distance is he not required to go to the masjid for every prayer?
Example, if it took someone one hour per trip to the Masjid and back to work or home. (That is 20 minutes to go to Masjid, 20 minutes at masjid and 20 minutes back to work or home.) Also this is the only Masjid in the city.
Praise be to Allah.The Importance of Congregational Prayer in Islam
It is obligatory for men to attend the prayer in congregation in the mosque. Not praying in congregation is one of the signs of hypocrisy. The further away one’s house is from the mosque, the greater the reward.
It was narrated that Abu Musa said: The Prophet (peace and blessings of Allah be upon him) said: “The people who will have the greatest reward for prayer are those who come the furthest distance. (Narrated by Al-Bukhari, 623 and Muslim, 622)
Who Is Obligated to Pray in the Mosque?
Prayer in congregation is obligatory for those who live close to the mosque, not for those who live far away.
The Sunnah describes those who are regarded as living close to the mosque as being those who can hear the call to prayer.
Hearing the Call to Prayer: Determining Proximity to the Mosque
What is meant is those who can hear the call to prayer from the mosque with no amplification of the Mu’dhdhin’s voice, when the Mu’dhdhin raises his voice, and there is no wind or noise etc., to interfere with hearing it.
Muslim (653) narrated that Abu Hurayrah (may Allah be pleased with him) said: A blind man came to the Prophet (peace and blessings of Allah be upon him) and said, “O Messenger of Allah, I do not have anyone to guide me to the mosque,” and he asked the Messenger of Allah (peace and blessings of Allah be upon him) to grant him a concession allowing him to pray in his house, and he granted him that. Then when he turned to leave, he called him back and said, “Can you hear the call to prayer?” He said, “Yes.” He said, “Then respond to it.”
Ibn Majah (793) narrated from Ibn `Abbas (may Allah be pleased with him) that the Prophet (peace and blessings of Allah be upon him) said: “Whoever hears the call to prayer and does not respond, there is no prayer for him (i.e., his prayer is not valid), except for the one who has an excuse.” (Classed as authentic by Al-Albani in Sahih Al-Jami`, 637.
An-Nawawi (may Allah have mercy on him) said in Al-Majmu`, 4/353:
“What is meant by hearing the call to prayer is when the muezzin stands at the edge of the town and other sounds are silent and the wind is still, and one is listening out. If a person can hear him, he is obliged (to attend prayers in congregation), and if he cannot hear him then he is not obliged.”
The Standing Committee was asked: If I can hear the muezzin from a distance of eight hundred meters, should I pray where I am or go to the mosque where the call to prayer was made?
They replied:
You have to go to this mosque and pray there with the congregation, or in any other mosque that may be easier for you, so long as you are able to do that… then the Committee quoted as evidence the two Hadiths mentioned above.
The Committee was also asked about a man who lives on the eighth floor and the mosque is about 500 meters away from him. Is it permissible for him to offer the prayers in congregation with his family members in his apartment?
They replied:
Congregational prayer in the mosque is obligatory, so you have to attend the mosques and pray the obligatory prayer there with the Muslims. You do not have the right to a concession allowing you to pray at home with your family because of this distance. (End quote from Fatawa Al-Lajnah Ad-Da’imah, 8/59)
Shaykh Ibn `Uthaymin (may Allah have mercy on him) was asked:
Is there any definition of the distance between one’s house and the mosque?
He replied:
“There is no specific distance defined in Shari`ah, rather that depends on people’s customs or the distance within which the Adhan can be heard without a microphone. (End quote from As’ilat Al-Bab Al-Maftuh, question no. 700)
Exceptions to Mosque Attendance: What If You Live Far Away?
Shaykh Ibn Baz (may Allah have mercy on him) said:
The one who can hear the call to prayer given in a regular voice without amplification is obliged to respond and to come and pray in congregation in the mosque in which the call is given…
But for those who live far away from the mosque and cannot hear the call to prayer except with amplification do not have to come to the mosque. They and those who are with them may pray in a separate congregation. If they take the trouble to attend the prayer with the congregation in the mosque whose call to prayer they cannot hear except with amplification because they are too far away, that will bring them a greater reward. (End quote from Majmu` Fatawa Ash-Shaykh Ibn Baz, 12/58)
And Allah knows best.