The answer is yes and no. Many people who have demons usually have bad dreams and after deliverance, the attacks in the dreams disappear. The enemy loves to attack us while we sleep using nightmares, horror dreams, or snakes, and spiders appearing in dreams. It’s the work of Satan---his goal is to rob our peace and power. “But while men slept, his enemy came and sowed tares among the wheat and went his way” (Matthew 13:25).
With that said, I don’t believe you can receive a demon through sleep. Nor do I believe that you can get saved in your sleep, even if you do see Jesus in a dream. For example, God showed up to kings like Abimelech, Pharaoh, and Nebuchadnezzar of Babylon, but it didn’t mean that they got in right standing with God via a dream. Our relationship with God is built on our faith while in our conscious state. Being attacked in a dream is not a sign that you have demons. But the enemy loves to use nightmares to bring confusion and fear into our life so that when we are in our conscious state, we give him that open door to traumatize us.
If you are attacked regularly in your sleep, you need deliverance. If it’s not frequent, exercise dominion over it. When Samson went to sleep, Delilah cut his hair off. Compare it to Jacob. When he went to sleep, God visited him in a dream. Samson lost his hair while sleeping; Jacob got a revelation while sleeping. One was sleeping on the rock, the other on the lap of Delilah. The question we have to ask ourselves is what “pillow” do we put our mind on before going to sleep? The lap of Delilah (compromise, bad tv shows, movies, music) or the Rock of Ages (worship, scripture, fellowship with believers)?
Before you go to sleep, read the Scriptures instead of being on your phone or watching TV. Meditate on the Word of God before you fall asleep. Commit your night to the Lord in prayer and praise. If you wake up with a nightmare, rebuke it right away. You can pray something like this, “In the name of Jesus, I rebuke this attack of the devil. I don’t accept this dream as reality. I believe in what God says about me. I am covered by the blood of Jesus.” Something as simple as this prayer will stop the nightmares from coming back. Avoid filling yourself with junk during the day (ungodly influences from music, movies, or bad company). What you do during the day does affect your dreams. If night terrors continue, seek prayer from your group leader or pastor to help you overcome the bad dreams.