Zayd bin Thabit reported,

The Messenger of Allah ﷺ partitioned off a small enclosure using a palm-leaf mat or a reed mat, and he came out to pray within it. Some men followed him there and joined him in his prayer.Then they came one night and waited, but the Messenger of Allah ﷺ was slow in coming out to them. He did not come out, so they raised their voices and threw pebbles at the door. The Messenger of Allah ﷺ came out to them angry and said to them, "Your persistence has gone on until I feared that this prayer would be made obligatory upon you. So pray in your homes, for the best prayer a person offers is in his home, except for the obligatory prayers."

Azami 2411

Sahih

عن زيد بن ثابت قال

احتجر رسول الله ﷺ حجيرة بخصفة أو حصير، فخرج رسول الله ﷺ يصلي فيها. قال: فتتبع إليه رجال، وجاوا يصلون بصلاته، قال: ثم جاؤا ليلة فحضروا. وأبطا رسول الله ﷺ عنهم، قال: فلم يخرج إليهم، فرفعوا أصواتهم، وحصبوا الباب، فخرج إليهم رسول الله ﷺ مغضبا فقال لهم رسول الله ﷺ: مازال بكم صنيعكم حتى ظننت أنه سيكتب عليكم. فعليكم بالصلاة في بيوتكم، فإن خير صلاة المرء في بيته إلا الصلاة المكتوبة.

الأعظمي 2411صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Sunnah prayers and voluntary prayers in general
Section
Virtue of praying voluntary prayers at home
Numbering
Jami al-Kamil 2411 (2nd edition)
Azami 2411