Anas bin Malik reported,

Banu Salama wished to relocate closer to the mosque, but the Messenger of Allah ﷺ disliked that Madinah be left empty. He said, "Banu Salama, will you not seek the reward for your footsteps?" So they remained where they were.

Bukhari 1887

Sahih

حدثنا ابن سلام أخبرنا الفزاري عن حميد الطويل

عن أنس رضي الله عنه قال

أراد بنو سلمة أن يتحولوا إلى قرب المسجد فكره رسول الله ﷺ أن تعرى المدينة وقال يا بني سلمة ألا تحتسبون آثاركم فأقاموا

البخاري 1887صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Virtues of Madinah
Chapter
Prophet's ﷺ dislike of Madinah being left unprotected
Numbering
Darussalam 1887
Bukhari 1887