Q. Dear Rabbi. I heard that it is forbidden to sleep in a house or a room all by yourself, since it is a 'Sakanah' or dangerous; is that true? Does it apply to women also?
A. Indeed, Talmud (Shabbat 151b) teaches that 'It is forbidden to sleep alone in a house and whoever sleeps alone in a house will be seized by Lilith (the mother of all demons, according to the Zohar - Pekudei 276b). The above is quoted also by Mishna Berura (239: 9).
However, Meiri (ad. loc.) mentions that if one finds himself in such situation, he should have trust in Hashem and engage in Torah learning, which affords outstanding protection.
Knesses Hagedola and Magen Avrohom (ibid.) maintain that it applies even for sleeping alone in a room.
Aruch Hashulchan (ibid.) is of the opinion that it does not apply if there are other people in the house
Kaf Hachaim (ibid.) mentions that it applies also to women.
Rabbi A. Bartfeld as revised by Horav Dovid Pam, Horav Aharon Miller and Horav Chanoch Ehrentreu Shlit'a