Abu Hurairah reported,

The Messenger of Allah ﷺ said, "Satan ties three knots at the back of the head of one of you when he sleeps. At each knot he strikes, saying, 'You have a long night ahead, so sleep on.' If the person wakes and remembers Allah, one knot is undone. If he performs ablution, another knot is undone. If he prays, the last knot is undone, and he rises in the morning energetic and in good spirits. Otherwise, he wakes up ill-tempered and sluggish."

Bukhari 1142

Sahih

حدثنا عبد الله بن يوسف قال أخبرنا مالك عن أبي الزناد عن الأعرج

عن أبي هريرة رضي الله عنه

أن رسول الله ﷺ قال يعقد الشيطان على قافية رأس أحدكم إذا هو نام ثلاث عقد يضرب كل عقدة عليك ليل طويل فارقد فإن استيقظ فذكر الله انحلت عقدة فإن توضأ انحلت عقدة فإن صلى انحلت عقدة فأصبح نشيطا طيب النفس وإلا أصبح خبيث النفس كسلان

البخاري 1142صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tahajjud
Chapter
Devil's knot on the back of the head when one does not pray at night
Numbering
Darussalam 1142
Bukhari 1142