Tips / Nginx

How to fix open() “/var/cache/nginx/” failed (13: Permission denied) while reading upstream error

While developing apps running on Nginx, sometimes you may face this kind of error:
open() “/var/cache/nginx/” failed (13: Permission denied) while reading upstream error.

Investigating Nginx logs will show you something like this:

2015/07/25 11:37:44 [crit] 27955#0: *5607 open() "/var/cache/nginx/fastcgi_temp/7/01/0000000017"
 failed (13: Permission denied) while reading upstream, client:, server:,
 request: "GET /wp-admin/admin.php?page=theme_options HTTP/1.1", 
upstream: "fastcgi://unix:/tmp/php5-fpm.sock:", host: "", referrer: 

What causes the issue?

Most of the time, it’s caused by wrong file permissions or wrong ownership of the files/directories. When this happens, Nginx can’t read and write into those directories, and the result is that your information can not be displayed correctly.

How can you fix it?

The fix for this issue is simple. Try to change the owner of the cache directory:

chown nginx.nginx /var/cache/nginx/ -R

or if you are running Nginx as Apache user (nobody):

chown nobody.nobody /var/cache/nginx/ -R

If that doesn’t work, try removing the directories inside /var/cache/nginx/. Then, restart Nginx and it will automatically create the directories again:

service nginx restart


Popular search terms:

  • nginx permission denied
  • nginx 13: permission denied
  • nginx /var/cache/nginx/fastcgi_temp/ permission denied
  • open() failed (13: Permission denied)

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking