unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 687 forks source link

unlink() : Permission denied [core/uwsgi.c line 1596] #892

Open bitcity opened 9 years ago

bitcity commented 9 years ago

I've installed uwsgi==2.0.10 on Ubuntu and using it with nginx. When I stop uwsgi service with vacuum=True, I get an error message in the log file:

SIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
...
goodbye to uWSGI.
unlink() : Permission denied [core/uwsgi.c line 1596]

The pid file (owned by root) and socket file (owned by www-data) are both left behind (i.e. not cleaned up by vacuum). It looks like I can ignore this error because it goes away when vaccum=False. However, I'm wondering what's causing this. I've also tried pidfile2 option. That throws 2 unlink errors, one on line 1575 and other on 1596 (same as above).

xrmx commented 8 years ago

For reference the error is possibly because of uwsgi (correctly) not running as root not being able to delete files owned by root. Closing.

bitcity commented 8 years ago

uwsgi (correctly) not running as root not being able to delete files owned by root.

However, I've noticed that socket file (not owned by root) is also left behind.

xrmx commented 8 years ago

@bitcity post your full config please

bitcity commented 8 years ago
[uwsgi]

env    = DJANGO_SETTINGS_MODULE=site.settings
chdir  = /var/www/site
home   = /home/user/virtualenv
module = site.wsgi:application

pidfile = /run/site.pid
socket  = /run/site.sock
logto   = /var/log/uwsgi/uwsgi.log

uid = www-data
gid = www-data

chown-socket = www-data:www-data
chmod-socket = 664

master = True
vacuum = True

die-on-term  = True
max-requests = 5000
processes    = 5
post-buffering = 1
memory-report  = True
xrmx commented 8 years ago

@bitcity thanks. What does ls -l /run/site.pid /run/site.sock says?

bitcity commented 8 years ago
-rw-r--r-- 1 root       root          5 Oct  9 08:45 site.pid
srw-rw-r-- 1 www-data   www-data      0 Oct  9 08:45 site.sock
bitcity commented 7 years ago

@xrmx Still face the same problem (after upgrade to 2.0.12). Error is :

unlink(): Permission denied [core/uwsgi.c line 1621]
foxmadr commented 6 years ago

I have similar configuration like bitcity and have the same problem on Ubuntu 16.04.

I tried to modify uwsgi.ini to: chmod-socket=1 chown-socket=root:root but it didn't help.

foxmadr commented 6 years ago

The problem is with access rights to /var/run folder. Switch socket folder to e.g. /tmp solves it.

Arpit-Ayush commented 1 year ago

Hi I am facing same issue. On searching online the answer I found suggested to delete the socket file and try running the .service file again but it was still showing error : " bind(): Permission denied [core/socket.c line 230]". Then I recreated a socket file with the same name and changed permission for my user but it's still showing the previous error: "error removing unix socket, unlink(): Permission denied [core/socket.c line 198]"

tlskinneriv commented 6 months ago

No idea if this is related or not, but we ran into this error message as part of an Ansible Automation Platform installation on top of RHEL 8. For us, it turned out that the configured max-requests option for uwsgi was greater than the sysctl option net.core.somaxconn (which was 128 out of the box for us). Once the sysctl option was fixed to be at least the value of the max-requests option, uwsgi proceeded to run. No idea why this error message is shown for this particular issue. To get to the bottom of it during troubleshooting, I had to strip the config down the the minimal parameters and start adding options until it broke.