Fix Nginx 403 Forbidden Once Serving Static Files

It’s been 3 days I’m facing an issue on my nginx that always got an error 403 forbidden once I opening my static file on my website.

I’ve tried googling with these keywords, but still got no solution:

The only one clue that I had from nginx logs is only “permission denied”.

$ sudo tail -f /var/log/nginx/error.log
$ 2016/02/13 08:27:23 [error] 19693#0: *14 open() "/root/projects/portofolio/static/admin/css/base.css" failed (13: Permission denied), client:, server:, request: "GET /static/admin/css/base.css HTTP/1.1", host: ""

I have tried to change my project permission, my static file permission, user that execute my nginx and permission denied still appear. I have asked to some of my friends one of them told me that I have to check my “nginx.conf“.
At that time, I thought I need to check file permission, but I think that I misunderstanding with my friend suggestion. Then I checked my “nginx.conf” and yeahhh!! I just know that “nginx.conf” had user config that we have to set.
By default “nginx.conf” user is “www-data“.

user www-data;
worker_processes 4;
pid /run/;

Then I replaced with my VPS user and solved my problem. 😀

user my_user;
worker_processes 4;
pid /run/;

I’ve got really really good experience at this first deploying app.
Stupid, eh? 😀

1 thought on “Fix Nginx 403 Forbidden Once Serving Static Files”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.