(98)Address already in use
|This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)|
| These are primarily notes|
It won't be complete in any sense.
It exists to contain fragments of useful information.
- usually also make sock: could not bind to address
- regularly also mentioning an IP/port combination
Generally means something is already bound and listening on the relevant address+port combination.
Can also mean that something very recently used it -- which means it often pops up on daemons that restart, as they tend to never change ports.
Daemons can can choose to ignore the potential and unlikely problem by using SO_REUSEADDR option while opening the socket.
Read up on the TIME_WAIT state of sockets. Shortish version: a TCP socket closed by this side will linger in this state for a minute or three, to ensure that possible delayed packets from the other end are properly ignored. This is largely to avoid packets accidental delivery into a different program that took the same port (though this is much less likely than it sounds: it happens only for identical local_ip+local_port+remote_ip+remote_port combinations. A host will typically have at least thousands of ports they cycle through, so it's unlikely to get the same IP on the same port).
One way to figure out what that is is:
netstat -lnp | less
...and see whether anything has the port in the 'Local Address'
If you get this error trying to start apache (and you've checked there is no other web server), it often means you have more than one Listen in your configuration, meaning apache fails because you told two parts to bind to the same (IP/)port.
Note the special case of 0.0.0.0 (and/or [::] when using IPv6) means 'bind on all interfaces (that are up)', so 0.0.0.0 plus a specific IP is also an effective duplicate.
To fix this, look/grep for Listen in all apache config (including vhost), and check that it's in there only once.
(Double mentions also seem to cause the "Unable to open logs" apache error (perhaps also a double-open?)(verify))