Sahih Muslim 12
Sahih Muslim · Book 1: The Book of Faith · Asking about the pillars of Islam
It is narrated on the authority of Thabit that Anas said:
حَدَّثَنِي عَبْدُ اللَّهِ بْنُ هَاشِمٍ الْعَبْدِيُّ ، حَدَّثَنَا بَهْزٌ ، حَدَّثَنَا سُلَيْمَانُ بْنُ الْمُغِيرَةِ ، عَنْ ثَابِتٍ ، قَالَ قَالَ أَنَسٌ كُنَّا نُهِينَا فِي الْقُرْآنِ أَنْ نَسْأَلَ رَسُولَ اللَّهِ صلى الله عليه وسلم عَنْ شَىْءٍ . وَسَاقَ الْحَدِيثَ بِمِثْلِهِ .
We were forbidden in the Holy Qur'an that we should ask about anything from the Messenger of Allah (ﷺ) and then Anas reported the hadith in similar words.