Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python socket.error: [Errno 98] Address already in use [closed]

when i setup application.py, it shows that socket.error: [Errno 98] Address already in use.

Traceback (most recent call last): File "application.py", line 121, in <module> main() File "application.py", line 117, in main http_server.listen(options.port) File "/usr/local/lib/python2.7/site-packages/tornado-3.1-py2.7.egg/tornado/tcpserver.py", line 117, in listen sockets = bind_sockets(port, address=address) File "/usr/local/lib/python2.7/site-packages/tornado-3.1-py2.7.egg/tornado/netutil.py", line 90, in bind_sockets sock.bind(sockaddr) File "/usr/local/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 98] Address already in use 
like image 628
emuu Avatar asked Jul 22 '13 05:07

emuu


People also ask

Why is my socket address already in use?

socket.error: [Errno 98] Address already in use This is because the previous execution has left the socket in a TIME_WAIT state, and can’t be immediately reused. There is a socket flag to set, in order to prevent this, socket.SO_REUSEADDR:

Why do I get socket error [errno 98] address already in use?

Running an example several times with too small delay between executions, could lead to this error: socket.error: [Errno 98] Address already in use. This is because the previous execution has left the socket in a TIME_WAIT state, and can’t be immediately reused. There is a socket flag to set, in order to prevent this, socket.SO_REUSEADDR:

How to make a socket immediately reusable when it is closed?

The cleanest way to make the socket immediately reusable is to follow the recommendation to first shutdown the client end ( socket) of a connection, and make sure the server's end shuts down last (through exception handling if needed).


1 Answers

There is obviously another process listening on the port. You might find out that process by using the following command:

$ lsof -i :8000 

or change your tornado app's port. tornado's error info not Explicitly on this.

like image 178
the5fire Avatar answered Sep 20 '22 05:09

the5fire