Sunan Ibn Majah, Book 20, Hadith 67 (Ibn Majah 2601)

It was narrated from Ibn Abbas that the Messenger of Allah (ﷺ) said:

“Do not carry out the legal punishment in the mosque.”