Ali bin Abu Talib reported,

The Messenger of Allah ﷺ taught me that whenever distress befalls me, I should say, "There is no god but Allah, the Forbearing, the Generous. Glory be to Allah, and blessed is Allah, Lord of the Mighty Throne. All praise belongs to Allah, Lord of the worlds."

Azami 11281

Sahih

عن علي بن أبي طالب قال

علمني رسول الله ﷺ إذا نزل بي كرب أن أقول: لا إله إلا الله الحليم الكريم، سبحان الله وتبارك الله رب العرش العظيم، والحمد لله رب العالمين.

الأعظمي 11281صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Supplications for various occasions
Section
What is said during distress, worry, grief, and hardship
Numbering
Jami al-Kamil 11281 (2nd edition)
Azami 11281