Nginx permission denied upstream error, even after 777

I have been getting this error

2013/03/13 13:25:07 [crit] 49299#0: *38 rename() "/var/tmp/nginx/fastcgi_temp/6/00/0000000006" to "/var/cache/nginx/microcache/8/fd/c36e398490d9b70e3c98ba094d065fd8" failed (13: Permission denied) while reading upstream

I tried other informations in Nginx and SO forums like changing the owner of folder/file, deleting the microcache folder for Nginx to create new by itself, but nothing seems to work.

My Nginx config has www as user(owner, in FreeBSD) all these folders /var/tmp/nginx/fastcgi_temp/ and /var/cache/nginx/microcache/ has www as user(owner) and wheel as group.

To test it I even gave -R 777 to those above mentioned folders and restart nginx, but error.log still says same error. Can't even think of what might possibly be wrong here, any guidance would be appreciated.


I fixed this up with giving permission to its parent directories. /var/cache/nginx all had Read Only permissions, while /var/cache/nginx/microcache/ had All permissions, it worked only after I changed /var/ , /var/cache/ and /var/cache/nginx/ permission to 766. This is still weird but it works for me.


I've had this error come up few times over last few days I've transitioned content from an old hardware server into AWS EC2 instance. To resolve, I've had to delete the /var/tmp/nginx/fastcgi_temp folder and restart nginx service. This recreates the fastcgi_temp folder and, at least for me, the problem went away after that.