Jabir bin Abdullah reported,

The Messenger of Allah ﷺ said, "There is no male or female except that upon his head, when he goes to sleep, Jareer ties three knots. If he wakes and remembers Allah, one knot is loosened. If he rises and performs ablution, another knot is loosened. And if he stands to pray, all his knots are loosened."

Azami 2691

Sahih

عن جابر بن عبد الله قال

قال رسول الله ﷺ: ما من ذكر ولا أنثى إلا وعلى رأسه جرير معقود ثلاث عقد حين يرقد، فإن استيقظ فذكر الله انحلت عقدة، فإذا قام فتوضا انحلت عقدة، فإذا قام إلى الصلاة انحلة عقده كلها.

الأعظمي 2691صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Minor actions do not invalidate the prayer
Section
Criticism of one who abandons the night prayer, 10
Numbering
Jami al-Kamil 2691 (2nd edition)
Azami 2691