Language:
كتاب النكاح
67  
Wedlock, Marriage (Nikaah)
(3)
Chapter: Whoever is not able to marry, is recommended to fast
(3)
باب مَنْ لَمْ يَسْتَطِعِ الْبَاءَةَ فَلْيَصُمْ
Sahih al-Bukhari 5066

Narrated `Abdullah:

We were with the Prophet (ﷺ) while we were young and had no wealth. So Allah's Messenger (ﷺ) said, "O young people! Whoever among you can marry, should marry, because it helps him lower his gaze and guard his modesty (i.e. his private parts from committing illegal sexual intercourse etc.), and whoever is not able to marry, should fast, as fasting diminishes his sexual power."

حَدَّثَنَا عُمَرُ بْنُ حَفْصِ بْنِ غِيَاثٍ، حَدَّثَنَا أَبِي، حَدَّثَنَا الأَعْمَشُ، قَالَ حَدَّثَنِي عُمَارَةُ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ يَزِيدَ، قَالَ دَخَلْتُ مَعَ عَلْقَمَةَ وَالأَسْوَدِ عَلَى عَبْدِ اللَّهِ فَقَالَ عَبْدُ اللَّهِ كُنَّا مَعَ النَّبِيِّ صلى الله عليه وسلم شَبَابًا لاَ نَجِدُ شَيْئًا فَقَالَ لَنَا رَسُولُ اللَّهُ صلى الله عليه وسلم ‏ "‏ يَا مَعْشَرَ الشَّبَابِ مَنِ اسْتَطَاعَ الْبَاءَةَ فَلْيَتَزَوَّجْ، فَإِنَّهُ أَغَضُّ لِلْبَصَرِ، وَأَحْصَنُ لِلْفَرْجِ، وَمَنْ لَمْ يَسْتَطِعْ فَعَلَيْهِ بِالصَّوْمِ، فَإِنَّهُ لَهُ وِجَاءٌ ‏"‏‏.‏
Reference : Sahih al-Bukhari 5066
In-book reference : Book 67, Hadith 4
USC-MSA web (English) reference : Vol. 7, Book 62, Hadith 4
  (deprecated numbering scheme)