It is reported concerning Sayyiduna Khalid bin al-Walid (may Allah be pleased with him) that he could not sleep, or he was afflicted with insomnia, so he complained of this to the Prophet (peace and blessings be upon him). Thereupon he (peace and blessings be upon him) ordered him to seek refuge at bedtime with these words: 'A'udhu bi-kalimati Allahi al-tammati min ghadabihi wa 'iqabihi wa sharri 'ibadihi, wa min hamazati al-shayatini wa an yahdurun' (I seek refuge in the perfect words of Allah from His anger, His punishment, the evil of His servants, and from the whisperings of the devils and from their coming to me). This narration also has a supporting narration (shahid) from the hadith of Sayyiduna Abdullah bin Amr bin al-As (may Allah be pleased with them both), which Imam Abu Dawud, Imam al-Nasa'i and Imam al-Tirmidhi recorded; Imam al-Tirmidhi declared it hasan (good), while Imam al-Hakim declared it sahih (authentic).
It is narrated from Sayyiduna Zayd bin Thabit (may Allah be pleased with him) that he said: "I complained to the Messenger of Allah (peace and blessings be upon him) of the insomnia that had afflicted me, so he (peace and blessings be upon him) said: 'Say: "Allahumma gharati al-nujum, wa hada'ati al-'uyun, wa anta hayyun qayyumun la ta'khudhuka sinatun wa la nawm, ya hayyu ya qayyum, ahdi' layli, wa anim 'ayni" (O Allah, the stars have set and the eyes have become still, while You are the Ever-Living, the Sustainer, Whom neither drowsiness nor sleep overtakes. O Ever-Living, O Sustainer, make my night peaceful and let my eye sleep).' So I said these words, and Allah, the Mighty and Majestic, removed from me the trouble I had been facing." This chain is da'if (weak) because Amr bin al-Husayn is weak; and Ibn Ulathah's name is Muhammad bin Abdullah bin Ulathah al-Uqayli.
Hadith Takhrij«هذا إسناد ضعيف؛ لضعف عمرو بن الحصين وابن علاثة اسمه محمد بن عبد الله بن علاثة العقيلي» «أخرجه المعجم الكبير للطبراني برقم: 4817، وأخرجه مجمع الزوائد ومنبع الفوائد برقم: 17071، وأخرجه المطالب العالية بزوائد المسانيد الثمانية برقم: 3365»