He used to sleep in the Prophet's mosque ﷺ during the time of the Messenger of Allah ﷺ, as he was a young unmarried man with no family.
أخبرنا عبيد الله بن سعيد قال حدثنا يحيى عن عبيد الله قال أخبرني نافع
أنه كان ينام وهو شاب عزب لا أهل له على عهد رسول الله ﷺ في مسجد النبي ﷺ
Bukhari narrated it in the Book of Prayer, Chapter on Men Sleeping in the Masjid, no. 440, from the hadith of Yahya Qattan, and Muslim narrated it in the Book of the Virtues of the Companions, Chapter on the Virtues of Abdullah bin Umar , no. 2479, from the hadith of Ubaydullah bin Umar with the same wording, and it is also found in al-Kubra, no. 801.