I'm trying to setup a server from Mac terminal.
I've established a connection on port 5000 and want to open another port in 5002
using this command:
python Blockchain.py -p 5002
But this gives the error:
OSError: [Errno 48] Address already in use
I tried to verify if port 5002 is open and listening. So I run
shell command lsof -i:5002
but it returns none.
Stacktrace
Error log & stacktrace attached below:
Traceback (most recent call last):
File "Blockchain.py", line 290, in <module>
app.run(host='0.0.0.0', port=5000)
File "/anaconda/envs/blockchain/lib/python3.6/site-packages/flask/app.py", line 841, in run
run_simple(host, port, self, **options)
File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 814, in run_simple
inner()
File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 774, in inner
fd=fd)
File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 666, in make_server
passthrough_errors, ssl_context, fd=fd)
File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 577, in __init__
self.address_family), handler)
File "/anaconda/envs/blockchain/lib/python3.6/socketserver.py", line 453, in __init__
self.server_bind()
File "/anaconda/envs/blockchain/lib/python3.6/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/anaconda/envs/blockchain/lib/python3.6/socketserver.py", line 467, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 48] Address already in use
Research
I've referred various answers on the same issue:
- socket.error: [Errno 48] Address already in use
- Flask and Pycharm socket.error
- Python - Socket Error, Address In Use
What I tried
Also, I tried the following methods to resolve the issue:
- Restarting the terminals
- Restarting PyCharm
- Running on different sockets (gives same error).
None of that seems to work. I'm fairly new to Python.
Any help is appreciated.