I have read in many places that when you sleep, spiders and insects might go in your mouth and you might swallow them while you are asleep. How do you stop this from happening and is it haram to swallow a spider?
All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
As for insects entering into the mouth of a sleeping person, though this is something possible but according to our knowledge, it is not practically, a common phenomenon, or a problem that needs a solution, and thus should not be a source of anxiety. All perfect praise be to Allaah.
Nonetheless, a Muslim should keep on reciting the morning and evening supplications as well as the supplications recited before sleeping, subsequently, Allaah will protect him from all evils.
As for eating spiders and other insects; eating them is not allowed due to their repulsiveness in nature. In addition, any person of sound health and reason repels from eating insects.
Allaah Says about the attributes of the Prophet (that which means) {…and makes lawful for them the good things and prohibits for them the evil things…}[Quran 7:157] Allaah also Says (that which means): {…Say, “Lawful for you are [all] good foods}[Quran5:4].
The Shaafi'ee, Hanbali, Hanfi and a group of Maaliki scholars are of the position that eating insects is forbidden.
However, a sleeping person is not held accountable for eating insects for the saying of the Prophet : "The pen is lifted (stops from recording deeds) from three kinds of people: a sleeping person until he wakes up, a child until he reaches the age of puberty and an insane person until he start reasoning." [Ahmad and others]
Allaah Knows best.
You can search for fatwa through many choices