If one experiences bad dreams, fear, uneasiness or sleeplessness at night, he should recite the following duaa:
بِسمِ اللهِ أَعُوذُ بِكَلِمَاتِ اللهِ التَّامَّاتِ مِن غَضَبِهِ وَعِقَابِه وَشَرِّ عِبَادِهِ وَمِن همَزَاتِ الشَّيَاطِين وَأَن يَحْضُرُون
In the name of Allah Ta’ala. I seek protection through the complete words of Allah Ta’ala from His anger, His punishment, the evil of His servants, the whispers of the Shayateen and of their presence.
عن عمرو بن شعيب عن أبيه عن جده قال كان رسول الله صلى الله عليه وسلم يعلمنا كلمات نقولهن عند النوم من الفزع بسم الله أعوذ بكلمات الله التامات من غضبه وعقابه وشر عباده ومن همزات الشياطين وأن يحضرون قال فكان عبد الله بن عمرو يعلمها من بلغ من ولده أن يقولها عند نومه ومن كان منهم صغيرا لا يعقل أن يحفظها كتبها له فعلقها في عنقه (مسند احمد رقم 6696)
Hadhrat Abdullah bin Amr (Radhiyallahu Anhu) reports: “Rasulullah (Sallallahu Alaihi Wasallam) taught us to recite the following duaa when we become frightened while sleeping (due to seeing a bad dream).
أَعُوذُ بِكَلِمَاتِ اللهِ التَّامَّاتِ مِن غَضَبِهِ وَعِقَابِه وَشَرِّ عِبَادِهِ وَمِن همَزَاتِ الشَّيَاطِين وَأَن يَحْضُرُون
Hadhrat Abdullah bin Amr (Radhiyallahu Anhu) used to teach his children to recite this duaa at the time of retiring to bed. From his children, those who were minors and were unable to learn the duaa, he used to write it on a page and tie it to their necks.
Source: Ihyaauddeen.co.za