Skip to content

Troubleshooting 403 Forbidden in NGINX

NGINX · Self-help guide

A 403 Forbidden error means NGINX understood the request but refused to serve the content. This is usually caused by missing index files, incorrect file permissions, blocked access rules, or a website root pointing to the wrong directory.

Step 1: Check your server block root path. Open the site configuration:

sudo nano /etc/nginx/sites-available/example.com

Confirm the root points to the correct folder, such as:

/var/www/example.com/public

Step 2: Make sure an index file exists:

ls -la /var/www/example.com/public

For a static site, you usually need index.html. For a PHP site, you may need index.php.

Step 3: Check permissions. NGINX normally runs as www-data on Ubuntu. Use:

sudo chown -R www-data:www-data /var/www/example.com sudo find /var/www/example.com -type d -exec chmod 755 {} ; sudo find /var/www/example.com -type f -exec chmod 644 {} ;

Step 4: Test the configuration:

sudo nginx -t

Step 5: Reload NGINX:

sudo systemctl reload nginx

Step 6: Check logs:

sudo tail -f /var/log/nginx/error.log

If the log says directory index is forbidden, it usually means there is no index file and directory listing is disabled. That is normally a good security default. Add the correct index file or update the index directive.

For Laravel and other modern PHP apps, the public folder must be the web root. Do not point NGINX to the full project root, because that may expose private files such as .env, storage, vendor, and application code.

Did this solve it?If not, Penny and the support team are ready to help.Start live chatOpen a ticket