Lord Vishnu is said to be the universal protector, out of the holy trinity (Brahma, Vishnu and Shiva). The following is a powerful mantra that invokes Lord Vishnu to get protection from nightmares, miseries and evil entities.
Chant this mantra 9 times every night before you sleep. Try to face the west direction while repeating the mantra. As you chant the mantra, touch the floor with the ring finger of your right hand. With the blessings of Lord Vishnu , you will not have any nightmares.