Can't run uwsgi as root, "bind(): Permission denied" Can't run uwsgi as root, "bind(): Permission denied" linux linux

Can't run uwsgi as root, "bind(): Permission denied"


I was having this problem. Running without setting the group and user ids solved the problem. I'll probably revisit this when I have more time to fix file permissions for the directory, but it works for the moment

/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals

EDIT I've had time to revisit this answer and I'd have to say that this is not good practice when running uwsgi in production.

The problem with the tutorial as written is that it assumes that www-data is a user and that the www-data user and group has access to all the files it needs on your server; in particular the socket file. Replace the appropriate arguments with your user and group and and you'll be good to go (and won't leave a gaping security hole on your server).

So, the correct command (if I was user ovangle in group ovangle would be):

/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid ovangle --gid ovangle

It would be better to create a user which has the specific permissions it needs to run the server successfully, but that's left as an exercise for the reader.


I don't know why the permissions don't work, but I ran into the same problem.

One quick way to fix this is to move the sockets to /tmp though! (Which is a fairly reasonable place to keep sockets anyway...)

so just update the uwsgi config with:

socket          = /tmp/mysite.sock

and the nginx-config with:

upstream django {    server unix:///tmp/mysite.sock;}

and it'll start working!


You did the permissions backwards.

uwsgi is running as www-data.

Your socket is in kk's home directly which is presumably owned by the kk user and the kk group.

You made it so that kk can access everything that www-data owns, not so www-data can access what kk owns.

You want to add the www-data to kk's group. This way www-data can reach the socket in kk's home.

usermod www-data -aG kk

Confirm with groups www-data and you should get back www-data : www-data kk showing that www-data is now in kk's primary group.

Now, provided kk's home folder permissions have at least '6' for the group permission www-data can read and write to the socket as necessary. E.g. chmod 660 /home/kk/XXXXXXX/mysite.sock.