Abu Talha reported,

We were sitting in the courtyards talking when the Messenger of Allah ﷺ came upon us, stood over us, and said, "What is it with you and these gatherings in the pathways? Avoid sitting in the pathways."We replied, "We only sat down for no harmful purpose. We sat to remember and converse with one another."He said, "If you must, then fulfill its rights, lowering the gaze, returning the greeting, and speaking kindly."

Azami 14766

Sahih

عن أبي طلحة

كنا قعودا بالأفنية نتحدث، فجاء رسول الله ﷺ، فقام علينا فقال: ما لكم ولمجالس الصعدات اجتنبوا مجالس الصعدات، فقلنا إنما قعدنا لغير ما بأس قعدنا نتذاكر ونتحدث، قال: إما لا، فأدوا حقها غض البصر، ورد السلام وحسن الكلام.

الأعظمي 14766صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Superior moral conduct
Chapter
Etiquette of the road, walking, and travel
Section
Rights of the road
Numbering
Jami al-Kamil 14766 (2nd edition)
Azami 14766