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:29:65

And when they board a ship, they supplicate Allah, sincere to Him in religion. But when He delivers them to the land, at once they associate others with Him  

And when they board the ship, they call on God, making their supplications purely to Him, in other words, they do not call on any other besides Him, suffering distress which only He is able to remove; but when He delivers them to land, behold! they ascribe partners, to Him,
القرآن:٢٩:٦٥

فَإِذَا رَكِبُوا فِي الْفُلْكِ دَعَوُا اللَّهَ مُخْلِصِينَ لَهُ الدِّينَ فَلَمَّا نَجَّاهُمْ إِلَى الْبَرِّ إِذَا هُمْ يُشْرِكُونَ  

{فإذا ركبوا في الفلك دعوا الله مخلصين له الدين} أي الدعاء، أي: لا يدعون معه غيره لأنهم في شدة لا يكشفها إلا هو {فلما نجّاهم إلى البر إذا هم يشركون} به.