Places Where Prayer Is Not Allowed
Question

Can you tell me of the seven forbidden places in which it is not permissible to pray?
Praise be to Allah.Hadiths on places where prayer is not allowed
Perhaps you are referring to the Hadith which was narrated by at-Tirmidhi (346) and Ibn Majah (746) from Ibn `Umar (may Allah be pleased with him), which says that the Messenger of Allah (blessings and peace of Allah be upon him) forbade praying in seven places: garbage dumps, slaughterhouses, graveyards, the middle of the road, bathrooms, camel pens and on top of the Ka‘bah. But this Hadith is inauthentic.
At- Tirmidhi said, after quoting this Hadith: “The Isnad (chain of narrators) of the Hadith of Ibn ‘Umar is not that strong.”
It was also classed as inauthentic by Abu Hatim Ar-Razi, as it says in Al-‘Ilal by his son (1/148); by Ibn Al-Jawzi in Al-‘Ilal Al-Mutanahiyah (1/399); Al-Busiri in Misbah Az-Zujajah (1/95); Ibn Hajar in At-Talkhees (1/531-532); and Al-Albani in Al-Irwa’ (1/318).
Based on that, it is not valid to quote this inauthentic Hadith to prove that it is not allowed to pray in these places. But in the case of some of these places, it is proven that it is not allowed to pray in them, in other Hadiths that are authentic, such as the Hadith narrated by Abu Dawud (492), At-Tirmidhi (317) and Ibn Majah (745) from Abu Sa`id Al-Khudri (may Allah be pleased with him), who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “All the earth is place of prostration, apart from graveyards and bathrooms.”
Shaykh Al-Islam (may Allah have mercy on him) said: “Its Isnad is good.” (Iqtida’ As-Sirat Al-Mustaqim (p. 332); classed as authentic by Al-Albani in Al-Irwa’ (1/320)
Rulings pertaining to places where prayer is not allowed
Some of these places need to be discussed in detail:

Garbage dumps

This refers to places where garbage is thrown, and there may be impure things in these places, so it is not allowed to pray in them, because of the impurities that they may contain.
Moreover, even assuming that they are pure, they are filthy places, so it is not appropriate for a Muslim to stand before Allah, may He be Exalted, in such a place.

Slaughterhouses

These are places in which animals are slaughtered . That is because these places are contaminated with impurities, such as blood and filth.
But if there is a clean and pure (tahir) space in the slaughterhouse, it is valid to pray there.

Graveyards

These are places where there are graves , and it is not allowed to pray in them, lest that lead to worshipping graves or resembling those who worship graves.
An exception is made in the case of the funeral prayer, which it is valid to offer in the graveyard. It is proven that the Prophet (blessings and peace of Allah be upon him) offered the funeral prayer for a woman who used to clean the mosque, after she had been buried in her grave. (Narrated by Al-Bukhari, 460 and Muslim, 956)
Another place in which it is not allowed to pray is a mosque that has been built over a grave, because of the mutawatir reports which say that the Prophet (blessings and peace of Allah be upon him) cursed those who take graves as places of worship, and he forbade doing that.
Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
“These mosques that are built over the graves of prophets, righteous men, kings and others should be removed by being demolished or otherwise. This is a matter concerning which I know of no difference of opinion among the well-known scholars, and it is not recommended to pray in such mosques , with no difference of scholarly opinion of which I am aware. In our view it is not valid [to pray in such mosques], which is also the favoured view of the madhhab, because of the prohibition and curse that have been narrated concerning that, and because of other Hadiths." (Iqtida’ As-Sirat, p. 330)

The middle of the road

This refers to a road that is used by people; as for a disused road, or the side of the road where people do not walk or travel, it is not forbidden to pray there.
The reason for the prohibition on praying in the middle of the road is that it makes the way narrow and prevents people from passing, and it is a distraction to the worshipper himself, as he will be so distracted that he will be unable to pray properly.
Praying in the middle of the road is not recommended (disliked) and may be prohibited, if it harms people by preventing them from passing or the one who does that exposes himself to harm as a result of accidents and the like.
An exception from that is made in cases of need or necessity, such as Jumu`ah prayer or `Eid prayer in the street if the mosque is full. This is something that the Muslims often do.

Bathrooms

This refers to places where people wash themselves , as is well known.
The prohibition on praying in bathrooms is proven in the Hadith of Abu Sa`id (may Allah be pleased with him) that was quoted above, which indicates that prayers offered in bathrooms are invalid.
The reason for the prohibition on praying in bathrooms is that they are places that are frequented by the devils and where people’s ‘Awrah (parts of the body that must be covered in Islam) is uncovered.
The apparent meaning of the Hadith indicates that the prohibition applies to any space that comes under the heading of a bathroom, so there is no difference between the place where a person bathes or a place where he takes off his clothes.
If it is forbidden to pray in bathrooms, then it is more appropriate that it should be forbidden to pray in toilets or lavatories (which are places where people relieve themselves). The only reason why there is no specific prohibition on praying in toilets is the fact that any rational person who hears that the Prophet (blessings and peace of Allah be upon him) forbade praying in bathrooms will realise that this prohibition applies even more so to praying in toilets.
Hence Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
“There is no specific text regarding toilets [meaning the prohibition on praying in such places], because the matter was too clear to the Muslims to require any evidence." (Majmu` Al-Fatawa  25/240)

Camel pens

This refers to places in which camels shelter (barns) and also the places in which they gather after having drunk water.
The reason for this prohibition is that camel pens are places where devils reside, and if the camels are there, they will distract the worshipper and prevent him from focusing properly, because he will be worried about them bothering him.

On top of the Ka`bah

The scholars who regard that as disallowed say that it is because, in this case, the worshipper will not be facing in the direction of the qiblah; rather he will only be facing part of it, because part of the Ka`bah will be behind his back.
Other scholars are of the view that it is valid to pray on top of the Ka`bah , because it is proven that the Prophet (blessings and peace of Allah be upon him) prayed inside it in the year of the conquest [of Makkah], and praying on top of it is like that. In fact, praying on top of the Ka’bah is not easy nowadays.
Another place in which it is also not allowed to pray is:

Land that has been seized by force

If someone has seized land by force, it is prohibited for him to pray there, according to scholarly consensus.
An-Nawawi (may Allah have mercy on him) said in Al-Majmu` (3/169):
“Praying in land that has been seized by force is prohibited according to scholarly consensus.”
See also: Ash-Sharh Al-Mumti` (2/237-260); Sharh Bulugh Al-Maram by Ibn `Uthaymin (1/518-522); Hashiyat Ibn Qasim (1/537-547).
And Allah knows best.