uwsgi icon indicating copy to clipboard operation
uwsgi copied to clipboard

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

Open bitcity opened this issue 9 years ago • 11 comments

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).

bitcity avatar Apr 17 '15 10:04 bitcity

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

xrmx avatar Nov 03 '15 23:11 xrmx

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.

bitcity avatar Nov 04 '15 07:11 bitcity

@bitcity post your full config please

xrmx avatar Nov 04 '15 09:11 xrmx

[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

bitcity avatar Nov 04 '15 10:11 bitcity

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

xrmx avatar Nov 04 '15 10:11 xrmx

-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 avatar Nov 04 '15 10:11 bitcity

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

unlink(): Permission denied [core/uwsgi.c line 1621]

bitcity avatar May 26 '17 14:05 bitcity

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 avatar Nov 08 '17 11:11 foxmadr

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

foxmadr avatar Nov 08 '17 11:11 foxmadr

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]"

Arpit-Ayush avatar Feb 20 '23 11:02 Arpit-Ayush

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.

tlskinneriv avatar Mar 14 '24 22:03 tlskinneriv