why do i have error "Address already in use"? why do i have error "Address already in use"? flask flask

why do i have error "Address already in use"?


This error means that port 9002 is already in use by another process. As per your logs that process is uwsgi probably another instance of uWSGI is running on the same address (127.0.0.1:9002). May be the port was not released while you stop flask app and your wsgi server is restarted while you run touch touch_reload. You may try the following command to release the port.

sudo fuser -k 9002/tcp

If that is a tcp process and restart your wsgi server again to see if the port is already in use.


maybe you stop uwsgi by crtl + z:

  1. find the pid of process which take 8000

$ lsof -i:8000

result maybe is:

COMMAND  PID       USER   FD   TYPE ...uwsgi   9196       xxx    4u  xxx   ...

then

$ kill 9196


i have same issue, but the problem was in sqlalchemy, try to add this:

@app.teardown_requestdef shutdown_session(exception=None):    from extension import db    db.session.remove()