Hadithcore
Sahih Muslim, 2479 b
sahih

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.

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ عَبْدِ الرَّحْمَنِ الدَّارِمِيُّ، أَخْبَرَنَا مُوسَى بْنُ خَالِدٍ، خَتَنُ الْفِرْيَابِيِّ عَنْ أَبِي إِسْحَاقَ الْفَزَارِيِّ، عَنْ عُبَيْدِ اللَّهِ بْنِ عُمَرَ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، قَالَ كُنْتُ أَبِيتُ فِي الْمَسْجِدِ وَلَمْ يَكُنْ لِي أَهْلٌ فَرَأَيْتُ فِي الْمَنَامِ كَأَنَّمَا انْطُلِقَ بِي إِلَى بِئْرٍ ‏.‏ فَذَكَرَ عَنِ النَّبِيِّ صلى الله عليه وسلم بِمَعْنَى حَدِيثِ الزُّهْرِيِّ عَنْ سَالِمٍ عَنْ أَبِيهِ ‏.‏

References2 variants
In-Book Reference
Book 44, Hadith 201
USC-MSA web (English) reference
Book 31, Hadith 6058 (deprecated numbering scheme)