The Messenger of Allah ﷺ forbade celibacy.
أخبرنا إسمعيل بن مسعود قال حدثنا خالد عن أشعث عن الحسن عن سعد بن هشام
أن رسول الله ﷺ نهى عن التبتل
No references are available.
[Sahih] Ahmad narrated it, 6/125, 252, 257, from the hadith of Ashath bin Abdul-Malik through him, and it is also in Kubra, no. 322. The hadith has many corroborating narrations, including the previous hadith.