The Prophet ﷺ said, "Do not enter upon these people who were punished unless you are weeping. If you are not weeping, then do not enter upon them, for I fear that what struck them may strike you as well."
حدثنا سفيان حدثني عبد الله بن دينار
عن النبي ﷺ قال لا تدخلوا على هؤلاء القوم الذين عذبوا إلا أن تكونوا باكين فإن لم تكونوا باكين فلا تدخلوا عليهم فإني أخاف أن يصيبكم مثل ما أصابهم
Its isnad is sahih. Bukhari related it, 1:443 and 8:288, by way of Malik from Abdullah bin Dinar. He also related it, 95, by way of Mamar from Zuhri, from Salim, from his father. Muslim related something similar to it, 2:95, by way of Ismail bin Jafar from Abdullah bin Dinar, and by way of Yunus from Ibn Shihab Zuhri, from Salim, at greater length. Suyuti mentioned it in Durr Manthur, 4:104, and attributed it to Bukhari, Ibn Jareer, Ibn Munzir, and Ibn Abu Hatim, and Ibn Mardawayh only. He did not mention the Musnad or Sahih Muslim.These punished people are the people of Hijr, among the dwellings of Thamud, and the Messenger of Allah ﷺ gave them this prohibition while they were on their way to Tabuk. See Tarikh Ibn Kathir, 5:10-11.