While creating a Flask application, I got the title error when I modified the module many times with the server running.
OSError: [Errno 98] Address already in use
It's still a message, but it seems that "I can't use the address I'm trying to use now because I'm already using it elsewhere." In such a case, search for the error message by guessing that the port is full.
As a result of the search, the following articles were hit. https://qiita.com/ringCurrent/items/2413c795372baa7b479d
The error numbers are different between "48" and "98", but it is probably an environmental difference, so I will implement the solution without worrying about it.
(base) root@e8cf64ce12e9:/home/continuumio# lsof -i :5000
bash: lsof: command not found
Install quickly. (Use apt because OS is ubuntu)
(base) root@e8cf64ce12e9:/home/continuumio# apt install lsof
Reading package lists... Done
main.py
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, debug=True)
Check the process using port 5000 with the lsof command (Note that if you do not limit the target with the -i option, a large amount will be extracted.)
(base) root@e8cf64ce12e9:/home/continuumio# lsof -i :5000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 881 root 4u IPv4 237229 0t0 TCP *:5000 (LISTEN)
python 901 root 4u IPv4 237229 0t0 TCP *:5000 (LISTEN)
python 901 root 5u IPv4 237229 0t0 TCP *:5000 (LISTEN)
--kill end command. Noisy name. ---9 Forced termination -: Xxxx port number
Check the details with the "man command"
(base) root@e8cf64ce12e9:/home/continuumio# kill -9 901
that's all
Recommended Posts