The Messenger of Allah ﷺ said, "Whoever goes out seeking knowledge is in the path of Allah until he returns."
قال رسول الله ﷺ: من خرج في طلب العلم كان في سبيل الله حتى يررجع.
Tirmidhi (2647) narrated it from Nasr bin Ali, who said, "Khalid bin Yazid Ataki narrated to us, from Abu Jafar Razi, from Rabi bin Anas, from Anas bin Malik," and he related it. Tirmidhi said, "This is a hasan gharib hadith, and some of them narrated it without making it a raised report."I say, from this same route it was narrated by Ibn Abdul-Barr in Jami Bayan Ilm (271), and Bayhaqi in Madkhal (371). It was also narrated by Abu Naeem in Hilyah (1/290), and Ajurri in Akhlaq Ulama (48), both of them from the hadith of Khalid bin Yazid with his chain, similarly. Its chain of transmission is hasan due to the discussion surrounding Khalid bin Yazid Ataki, Abu Jafar Razi (who is Isa bin Abu Isa, well known by his kunyah), and Rabi bin Anas, for all of these are below the level of the reliable narrators. Their memory has been discussed, but none of them has been accused of fabrication to the point that their hadith would be dropped altogether. Narrators of this caliber have their hadith graded as hasan in matters of virtues, especially when there are corroborating reports and nothing in their hadith is objectionable.