Abu Hurairah reported,

The Messenger of Allah ﷺ said, "A prophet from among the prophets once stopped to rest beneath a tree, and an ant bit him. He ordered his belongings to be removed from under the tree, then commanded that the ants' nest be burned with fire. Allah revealed to him, 'Why not just one ant?'"

Azami 8490

Sahih

عن أبي هريرة

أن رسول الله ﷺ قال: نزل نبي من الأنبياء تحت شجرة فلدغته نملة. فأمر بجهازه فأخرج من تحتها، ثم أمر ببيتها فأحرق بالنار فأوحى الله إليه: فهلا نملة واحدة.

الأعظمي 8490صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Stories of the prophets
Chapter
Reports about unnamed prophets
Section
A prophet from among the prophets who burned an ant colony, so Allah rebuked him and reproached him for his action
Numbering
Jami al-Kamil 8490 (2nd edition)
Azami 8490