Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
EADDRINUSE
Edit
PageHistory
Diff
Info
LikePages
You are viewing an old revision of this page.
View the current version
.
!!!Address already in use This error means an address is already in use, this is frequently due to a network port or socket being already claimed by another process. You can't have two processes listen on the same IP address/port pair at the same time unless they actively cooperate to do so. For example, when starting apache a second time without closing down the first connection you get in the logs: Address already in use: make_sock: could not bind to port 80 You can tell whats listening on a port by using: netstat -ap (see netstat(8) for more information) kill(1) the other program that is listening on that port and try again. Usually you get this error when trying to start a daemon that is already running. This also occurs when a TCP socket is still timing out. If you stop a program that was listening then restart it again quickly, you may find you get this error. In this case either wait a few minutes (4 should do); or in the case that it is your own program; use the code below. ---- To code around this call unsigned int opt = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))==-1) { perror("setsockopt(fd,SOL_SOCKET, SO_REUSEADDR,1)"); !exit(1); }
4 pages link to
EADDRINUSE
:
connect(2)
bind(2)
listen(2)
TcpStates