Living on top of a Shul:[1]
A person is to beware not to live on top of a Shul due to danger. This especially applies if there is a bathroom on top of the shul. [The Taz lost a number of children as a punishment for doing so.[2] Accordingly, one is to be very careful not to designate an apartment in a building as a Shul, if there are other apartment complexes on top of it. Nonetheless, a number of leniency’s exist in a case of need that being stringent in this matter will cause a community to not have a synagogue. These leniencies include:[3] 1) If the Shul was built with a Tnaiy that it should not have the Kedusha of a Shul. 2) If on top of it there is no Shumush, and only the second floor above it does it. 3) Shomer Pesaim Hashem. There is no issue to live on top of the Ezras Nashim.[4]]
[1] See Michaber 151:12; Taz 151:4; M”A 151; Kneses Hagedola 151; M”B 151:42; Piskeiy Teshuvos 151:22; Sefer Shemiras Haguf Vihanefesh [Lerner] 209:4
[2] Taz ibid
[3] See Birkeiy Yosef 151:10; Chaim Sheol 1:56; Yabia Omer 6:26Minchas Yitzchak 2:48; 4:43; Shevet Halevi 1:27; 5:18; Piskeiy Teshuvos 151 footnote 154
[4] Ashel Avraham Butchach 151; Sefer Shemiras Haguf Vihanefesh [Lerner] 209:5
