Sometimes I found the server will failed to bind because the client has already used that port. Client has created a self connection like:
tcp 127.0.0.1:34567 -> 127.0.0.1:34567 ESTABLISHED
Client will create a self connection when the client is trying to connect localhost server port and the server is not started. The client will try to connect to server port using randon local port. The local port keeps changing untill it equals to the server port. Then the client will establish the connection with itself, and receive its own sent data. After that, the server will fail to start.
The client should disconnect that self connection and keep trying to connect using other local port. On connected, the client can check local port, and disconnect if equals server port.