← BYTES
Unix IPC·Starter·Ref: 15.1.32

If a server tries to restart and immediately re-bind to the same port it was just using, but gets an 'address already in use' error, what's a common underlying cause?

Have a question about this video? Mention reference 15.1.32 when you contact us.

a.The port number is invalid
b.The operating system has permanently banned that port number
c.The server has run out of disk space
d.Leftover TIME_WAIT sockets from the previous process's connections are still holding that same local port, and by default a new bind() to it can be refused until they clear
This is one of the most common real-world encounters with TIME_WAIT: a just-restarted server tries to bind its old listening port, but connections from the PREVIOUS process instance are still sitting in TIME_WAIT holding that port, and the bind() can fail with EADDRINUSE until they clear or the SO_REUSEADDR option is set (covered in the intermediate section).

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES15132#UnixIPC