Port congestion caused by ship detention is an important reason for the obstruction of the shipping supply chain. In this paper, a method of excavating the ship waiting behavior outside the port is proposed based on the automatic identification system (AIS) data and considering uncontrollable factors. Firstly, combined with the analysis of ship navigation behavior, the speed threshold of the ship waiting outside the port is defined through average speed. Secondly, the range of ships berthing in the port is distinguished, and the different waiting behavior of ships are clarified. Finally, the situation of different types and sizes of ships waiting outside the port is analyzed. The paper found that ships of different types and sizes have distinctive clustered waiting behavior, and there are significant differences in waiting time. At the ship type, bulk cargo ship have the highest number among ships waiting outside the port, followed by tanker and container ship; at the ship scale, basically, the number of ships waiting outside the port decreases with the increase of the scale, but the average waiting time is longer. It has an excellent practical promotion value for the application of AIS data and development of shipping.