Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

i run my flask app, and it works good, but by the time the app is stopped and in my uwsgi log

probably another instance of uWSGI is running on the same address (127.0.0.1:9002).
    bind(): Address already in use [core/socket.c line 764]

when i run touch touch_reload, app is working again. I run anything else on the server which may take the socket.

my conf:

nginx
server {
    listen 80;
    ....
    location / {
       include uwsgi_params;
       uwsgi_pass 127.0.0.1:9001;
    }
    ....
}
server {
    listen 80;
    ....
    location / {
       include uwsgi_params;
       uwsgi_pass 127.0.0.1:9003;
    }
    ....
}

uwsgi:
chdir = /var/www/../
module = wsgihandler
socket = 127.0.0.1:9003
wsgi-file = app/__init__.py
callable = app
master = true
chmod-socket = 664
uid = root
gid = root
processes = 4
socket-timeout = 180
post-buffering = 8192
max-requests = 1000
buffer-size = 32768
logto = /var/www/.../log/uwsgi.log
touch-reload = /var/www/.../touch_reload
like image 439
comalex3 Avatar asked Jun 18 '15 06:06

comalex3


People also ask

What does address already in use mean?

Address already in use means that the port you are trying to allocate for your current execution is already occupied/allocated to some other process.

Why does socket bind fail?

If you're seeing a "TCP/UDP: Socket bind failed on local address" error message in the OpenVPN log, it means your VPN connection is configured to bind to a fixed local address and/or port number, and that this address/port number is unavailable.

Can not bind to port?

The failed to bind to Port Minecraft server error occurs when a server attempts to use a service port (i.e 25565) that is already in use by another server. Since the majority of Minecraft hosting is Shared Hosting with shared IPs, the only way to make each server accessible is by giving it a unique port.


1 Answers

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

like image 135
zhangliang Avatar answered Sep 30 '22 19:09

zhangliang