uwsgi socket permissions

19,173

/run is a tmpfs which means it is not persistent across reboots. Create a directory /var/uwsgi instead which will be persistent.

Share:
19,173
Hanpan
Author by

Hanpan

Updated on August 01, 2022

Comments

  • Hanpan
    Hanpan over 1 year

    I'm running into some permission issues with uwsgi running on Ubuntu 12. Here is my ini file:

    [uwsgi]
    project = djangorpoject
    base_dir = /home/mysite/mysite.com
    
    uid = www-data
    gid = www-data
    plugins = http,python
    
    processes = 4
    harakiri = 60
    reload-mercy = 8
    cpu-affinity = 1
    max-requests =  2000
    limit-as = 512
    reload-on-as = 256
    reload-on-rss = 192
    no-orphans = True
    #vacuum = True
    master = True
    
    logto = /var/log/uwsgi/%n.log
    #daemonize = /var/log/uwsgi/%n.log
    #catch-exceptions
    disable-logging
    
    virtualenv = %(base_dir)/venv
    chdir = %(base_dir)
    module = %(project).wsgi:application
    
    socket = /run/uwsgi/%n.sock
    chmod-socket = 666
    chown-socket = www-data:www-data
    

    As you can see, I am running chmod and chown on the socket file. When I attempt to load my site, I am getting the following error:

    bind(): Permission denied [socket.c line 107]
    

    This goes away if I run

    sudo chown -R www-data:www-data /run/uwsgi
    

    But this doesn't persist when I reboot my server. I am assuming this is because uwsgi is recreating the folder on boot? Is there any way to permanently apply the permissions to socket?

  • Hanpan
    Hanpan over 11 years
    I tried this, but it doesn't seem to work either. /var/run appears to be identical to /run, are they symlinked?
  • Rob Wouters
    Rob Wouters over 11 years
    @Hanpan, you are right I should've checked. I've edited the answer.