Abu Hurairah reported,

Whenever a funeral procession passed by the Messenger of Allah ﷺ, he would ask the people whether the deceased had any debts.If they said yes, he would ask, "Did he leave behind enough to settle them?"If they said yes, he would pray over him. Otherwise, he would say, "Pray over your companion yourselves."

Ahmad 8950

Sahih

حدثنا سليمان بن داود قال أنبأنا أبو زبيد عن الأعمش عن أبي صالح

عن أبي هريرة قال

كان رسول الله ﷺ إذا مرت به جنازة سألهم عليه دين فإن قالوا نعم قال ترك وفاء فإن قالوا نعم صلى عليه وإلا قال صلوا على صاحبكم

أحمد 8950صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abu Hurairah
Numbering
Darussalam 8950
Ahmad 8950