عَنِ الْوَلِيدِ بْنِ الْوَلِيدِ أَنَّهُ قَالَ يَا رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ إِنِّي أَجِدُ وَحْشَةً قَالَ إِذَا أَخَذْتَ مَضْجَعَكَ فَقُلْ أَعُوذُ بِكَلِمَاتِ اللَّهِ التَّامَّةِ مِنْ غَضَبِهِ وَعِقَابِهِ وَشَرِّ عِبَادِهِ وَمِنْ هَمَزَاتِ الشَّيَاطِينِ وَأَنْ يَحْضُرُونِ فَإِنَّهُ لَا يُضَرُّ وَبِالْحَرِيِّ أَنْ لَا يَقْرَبَكَ
It is narrated from Sayyiduna Waleed bin Waleed (may Allah be pleased with him), he said: O Messenger of Allah! I feel loneliness. The Prophet (peace and blessings be upon him) said: When you come to your bed, recite this supplication: "A‘udhu bikalimatillahi at-tammati min ghadabihi wa ‘iqabihi wa sharri ‘ibadihi wa min hamazatish-shayateeni wa an yahdurun." (I seek refuge in the perfect words of Allah from His anger, His punishment, the evil of His servants, the whispers of devils, and from their presence near me.) Then the devil will not harm you; rather, it is most likely that he will not even come near you.