Skip to content
Advertisement

uwsgi failed to open python file /root/ … /wsgi.py (DJANGO)

/var/log/uwsgi/myapp.log:

JavaScript

I don’t understand the reason for the error: Tue Jan 11 15:27:45 2022 – failed to open python file /root/eva/lawyer/lawyer/wsgi.py I can’t understand why uwsgi can’t open this python file. The path to it is right

myapp.ini:

JavaScript

Tell me, please, what could be the cause of the error and how to solve it? This seems like an easy problem to solve. But I couldn’t find information about it on the Internet

Advertisement

Answer

Check your file permissions for the Django project.You have your WSGI worker configured to use the account ‘www-data’. Either change this to an account that has access to the directories and file, or change the files permissions.

You can validate the file permissions by running ls -la in the directory. The third column shows the owner and the fourth column shows the group.

JavaScript

You can change file and folder permissions by running chown www-data:www-data ./* in the project directory.

I do not recommend keeping the files in your root directory, that should be protected. Instead consider moving them to /var/www or /var/app.

To validate if its a permissions issue, you could change your uWSGI configuration to make the uid and gid root, but do not use this in a production setting.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement