Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:17:67

And when adversity touches you at sea, lost are ˹all˺ those you invoke except for Him. But when He delivers you to the land, you turn away ˹from Him˺. And ever is man ungrateful.  

And when distress, difficulty, befalls you at sea, ˹such as˺ fear of drowning, those whom you ˹are wont to˺ invoke are no longer present, ˹those whom˺ you ˹are wont to˺ worship of gods ˹are no longer present˺, and so you do not call on them — except Him, exalted be He, for on Him alone you do call, because you are suffering a distress which only He can remove. But when He delivers you, from drowning and brings you, to land, you are rejective, of ˹God’s˺ Oneness, for man is ever ungrateful, ˹ever˺ denying ˹God’s˺ graces.
القرآن:١٧:٦٧

وَإِذَا مَسَّكُمُ الضُّرُّ فِي الْبَحْرِ ضَلَّ مَنْ تَدْعُونَ إِلَّا إِيَّاهُ ۖ فَلَمَّا نَجَّاكُمْ إِلَى الْبَرِّ أَعْرَضْتُمْ ۚ وَكَانَ الْإِنْسَانُ كَفُورًا  

{وإذا مسكم الضر} الشدة {في البحر} خوف الغرق {ضل} غاب عنكم {من تدعون} تعبدون من الآلهة فلا تدعونه {إلا إياه} تعالى فإنكم تدعونه وحده لأنكم في شدة لا يكشفها إلا هو {فلما نجاكم} من الغرق وأوصلكم {إلى البر أعرضتم} عن التوحيد {وكان الإنسان كفورا} جحودا للنعم.