The Messenger of Allah ﷺ said, "The supplication of Dhun-Nun when he called out from within the belly of the whale was, 'There is no god but You, glory be to You. Indeed, I have been among the wrongdoers' [Anbiya 21:87]. No Muslim man ever supplicates with these words for anything without Allah answering him."
قال رسول الله ﷺ: دعوة ذي النون إذ دعا وهو في بطن الحوت {لا إله إلا أنت سبحنك إني كنت من الظلمين} فإنه لم يدع بها رجل مسلم في شيء قط إلا استجاب الله له.
Narrated by Tirmidhi (3505), Ahmad (1463), Nasai in Amal al-Yawm wal-Layla (656), and Hakim (2/382–383), all of them through Yunus bin Abu Ishaq, from Ibrahim bin Muhammad bin Saad, from his father, from Saad, who related it. Hakim said, "This is a hadith sahih in chain." Its chain is hasan because of Yunus bin Abu Ishaq, whose hadith is hasan.In Ahmad's version, there is a story at the beginning. Saad said, I passed by Uthman bin Affan in the masjid and greeted him with salaam, but he stared at me and did not return the greeting. So I went to the commander of the faithful, Umar bin Khattab, and said, "Commander of the faithful, has something happened in Islam?" I said it twice. He said, "No, and what is that?" I said, "Nothing, except that I passed by Uthman just now in the masjid and greeted him, and he stared at me and did not return the greeting."Umar sent for Uthman and summoned him, and said, "What kept you from returning your brother's greeting?" Uthman said, "I did no such thing." Saad said, "Indeed you did." He kept denying it and I kept insisting, until he swore an oath and I swore an oath. Then Uthman remembered, and said, "Yes indeed, and I seek Allah's forgiveness and turn to Him in repentance. You passed by me just now while I was reciting to myself a phrase I had heard from the Messenger of Allah ﷺ. By Allah, I never recall it except that a veil comes over my sight and my heart."Saad said, I will tell you what it was. The Messenger of Allah ﷺ mentioned to us the most excellent supplication, then a bedouin came and distracted him until the Messenger of Allah ﷺ got up. I followed him, and when I feared that someone might reach his house before me, I stamped my foot on the ground. The Messenger of Allah ﷺ turned to me and said, "Who is this, Abu Ishaq?" I said, "Yes, Messenger of Allah." He said, "What is it?" I said, "Nothing, by Allah, except that you mentioned to us the most excellent supplication, then this bedouin came and distracted you."He said, "Yes, it is the supplication of Dhun-Nun, when he was in the belly of the whale, "There is no god but You, glory be to You, indeed I have been among the wrongdoers" [Anbiya 21:87]. No Muslim ever supplicates to his Lord with it concerning anything at all except that He answers him."The hadith has other chains, but what I have mentioned is the soundest of them.