Sahih Muslim 6371
The Book of the Merits of the Companions
حَدَّثَنَا عَبْدُ اللَّهِ بْنُ عَبْدِ الرَّحْمَنِ الدَّارِمِيُّ، أَخْبَرَنَا مُوسَى بْنُ خَالِدٍ، خَتَنُ الْفِرْيَابِيِّ عَنْ أَبِي إِسْحَاقَ الْفَزَارِيِّ، عَنْ عُبَيْدِ اللَّهِ بْنِ عُمَرَ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، قَالَ كُنْتُ أَبِيتُ فِي الْمَسْجِدِ وَلَمْ يَكُنْ لِي أَهْلٌ فَرَأَيْتُ فِي الْمَنَامِ كَأَنَّمَا انْطُلِقَ بِي إِلَى بِئْرٍ . فَذَكَرَ عَنِ النَّبِيِّ صلى الله عليه وسلم بِمَعْنَى حَدِيثِ الزُّهْرِيِّ عَنْ سَالِمٍ عَنْ أَبِيهِ .
Ibn Umar reported:I used to spend nights in the mosque and by that time I had no wife and children. I saw in a dream as if I am being taken to a well. I made a mention of it to Allah's Messenger (may peacebe upon him). The rest of the hadith is the same
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.