Abstract Similar to other underwater robots, bionic robotic fish face entrapment risks when stranded due to wave action or water level drop. In this paper, we propose a locomotion strategy for a whale shark‐inspired robotic fish, enabling it to autonomously return to aquatic environments after being stranded on land. This strategy is informed by the terrestrial locomotion capabilities of mudskippers and is particularly significant given the considerable mass of such robotic fish, which compounds the difficulty of land‐based movement. First, we introduce a lightweight YOLOv5 model‐based algorithm for deep‐water area recognition, which identifies the direction for the bionic robot fish to re‐enter the water. Subsequently, pectoral fin‐based crawling gaits are designed by the innate two degrees of freedom within the existing pectoral fin structure of the robot. These gaits empower the robotic fish to move on a multitude of terrestrial terrains. Extended field experiments have validated the effectiveness of our water recognition algorithm and locomotion strategy, confirming the ability of the whale shark‐inspired robotic fish to perform successful water entry maneuvers from the shore. Additionally, the capability to traverse various landforms are also verified. This work provides valuable insights into self‐rescue mechanisms for stranding underwater robots and promotes practical applications of bionic robotics.