Praying in congregation in the mosque is obligatory for every adult male who is able to hear the call to prayer, according to the correct scholarly opinion, because Allah, may He be exalted, says (interpretation of the meaning): And establish prayer and give zakah and bow with those who bow [in worship and obedience] [al-Baqarah 2:43]. And there is other evidence which you may find in the answer to question no. 8918
What is meant by hearing the call to prayer is hearing it at a normal volume without any amplification when all other sounds are quiet and there is nothing to prevent you from hearing it. It should be noted that the mu'adhdhins at the time of the Prophet (blessings and peace of Allah be upon him) used to give the call to prayer from a high place, such as the roof of the mosque and the like, and the structure of the houses was such that the sound could be heard and carried, which made it possible for the voice of the mu'adhdhin to reach a considerable distance.
Based on that, at a distance of ten minutes walking it is ordinarily possible for the sound to reach you; in fact it could reach a distance further than that.
The Sunnah indicates that there is nothing wrong with praying in one's house and not going to pray in congregation in the mosque if there is an excuse for doing so. It was narrated from Ibn Abbaas (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: Whoever hears the call and does not come, his prayer is not valid, except for those who have an excuse. Narrated by Ibn Maajah (793); classed as saheeh by al-Albaani in al-Irwa', 2/337
Based on that, if a person fears for his life or fears extensive harm, or fears that he may be taken and put in prison wrongfully, this is regarded as an excuse for his not praying in congregation, and for offering the prayer in his house, so as to protect himself.
Ibn Qudaamah (may Allah have mercy on him) said in al-Mughni (1/366): The one who is afraid is excused for not offering prayers in congregation or praying Jumuah, because the Prophet (blessings and peace of Allah be upon him) said: A (valid) excuse is fear or sickness. End quote.
But if the place is safe and the dogs in the street only bark and do not harm anyone, then in that case you must go to the mosque.
If you can manage to get a car in which you can go to the mosque, that is good and more appropriate. It was narrated that Ubayy ibn Kab said: There was a man, and I do not know of any man who lived further away from the mosque than he did, but he never missed a prayer. It was said - or I said - to him: Why don't you buy a donkey that you can ride when it is dark or when the sand is too hot? He said: I would not like my house to be next to the mosque. I want my walking to the mosque and my returning when I come back to my family, to be recorded for me. The Messenger of Allah (sa) said: Allah has gathered all that (reward) for you. Narrated by Muslim (663)
If you answer the call of the mu'adhdhin, even though you are far away and you put up with the hardship of walking or come by car , that is good for you and is preferable, and Allah will record your footsteps and efforts to go to the mosque and return from it, if your intention is sincere.
And Allah knows best.
Reproduced from Islam QA