10

I'm using node.js with Nginx as web server running on Slackware 14.1.

I created a page that uploads a file. In my development machine (Debian like) it works fine, but in production (Slackware server) I get this error in /var/log/nginx/error.log:

2015/10/09 15:08:44 [crit] 1231#0: *5 open() "/var/lib/nginx/client_body/0000000003" failed (13: Permission denied), client: 10.0.0.22, server: localhost, request: "POST /home/perfil_usuario/upload HTTP/1.1", host: "aluno.fio.edu.br", referrer: "http://aluno.fio.edu.br/home/perfil_usuario/upload"

And Nginx returns a 500 Internal Server Error.

I searched and try the fixes from many posts but the error continues.

4
  • 1
    Check user owner for /var/lib/nginx is the same nginx process Oct 9, 2015 at 15:44
  • How I can do it @Feredico?
    – BrTkCa
    Oct 9, 2015 at 17:31
  • Start with ls -lrt /var/lib Oct 9, 2015 at 22:53
  • 1
    chmod +x /var/lib/nginx -R Nov 30, 2021 at 6:31

3 Answers 3

13

As the error message says, this is a Permissions issue.

This is usually caused by nginx process user (www-data for example) not have read/execute access to one of the parent directories.

Check through /var/lib/nginx/client_body/ and make sure the permission is correct at each directory level to solve the problem.

3
  • 1
    Had this same error appear after a patch changed directory permissions. The error only occurred when a user tried to upload a file > 20k Feb 18, 2020 at 23:16
  • 4
    @shonkylinuxuser That is the correct behavior, in case the request body is larger than the buffer (client_body_buffer_size default 8k|16k), the whole body or only its part is written to a temporary file (client_body_temp_path). Feb 18, 2020 at 23:26
  • Everyone copied this answer, but no one wrote what the correct permissions should be..
    – tpaksu
    Nov 27, 2020 at 10:50
1

In my case the issue was that the ownership of /var/lib/nginx was wrong. All other directories that nginx writes to were owned by www-data, whereas the 'nginx dir was owned by root. In this case the best solution is to change the directory ownership to match that of the other dirs that nginx writes to.

0

In my case the ownership of /var/lib/nginx was set to www-data:adm and permission was set to 770

Changes did worked me was

  1. chown root:root /var/lib/nginx/
  2. chmod 0755 /var/lib/nginx

Also the /var/lib/nginx/tmp was different, Updated the ownership and permission as per point 1 & point 2

and content within in /var/lib/nginx/tmp was mentioned

drwx------. 2 www-data root 6 Sep 29 23:37 uwsgi

drwx------. 2 www-data root 6 Sep 29 23:37 scgi

drwx------. 2 www-data root 6 Sep 29 23:37 fastcgi

drwx------. 10 www-data root 78 Oct 20 12:17 proxy

drwx------. 2 www-data root 6 Oct 20 12:20 client_body

After setting these permission and ownership, restart the nginx. And you wont see permission denied error and Nginx stopped giving 500 Internal server error and I was seeing expected result. Thanks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .