RackUp IT - View Cloud Hosting Plans

Get started now or speak directly with our engineering team for specialized assistance.

Logo
DevelopmentWEB & APPCalculatorTOOLServicesProductBlogOur TeamCareers
View Plans
Home>Blog>403 Forbidden in Nginx: 6 Causes and How to Fix Each One
VPS Hosting

403 Forbidden in Nginx: 6 Causes and How to Fix Each One

Alex Vance
Alex Vance
Published Oct 9, 2026· Updated Nov 13, 2026•✓ Verified Expert Reviewed•4 min read
403 Forbidden in Nginx guide cover

Key Takeaways

  • ✓403 means Nginx found the path but refuses to serve it.
  • ✓The error log line tells you whether it is a missing index, permissions, a deny rule or SELinux.
  • ✓Check every parent directory, not just the file, with namei -l.
  • ✓Make sure the 403 page is really from Nginx and not your app or Cloudflare.

Table of Contents

  • •403 Forbidden in Nginx: 6 Causes and How to Fix Each One
  • •Step 1: Check the Error Log
  • •Cause 1: No Index File in the Directory
  • •Cause 2: File Permissions
  • •Cause 3: A Parent Directory Blocks Access
  • •Cause 4: A deny Rule in the Config
  • •Cause 5: SELinux (RHEL, AlmaLinux, Rocky, Oracle Linux)
  • •Cause 6: The 403 Is Not From Nginx
  • •Test and Reload
  • •Frequently Asked Questions
  • •Rather Not Debug Nginx at 2 AM?

403 Forbidden in Nginx: 6 Causes and How to Fix Each One

A 403 Forbidden page with nginx at the bottom means Nginx received the request and found something at that path, but decided it is not allowed to serve it. Unlike a 404 Not Found, the path usually exists. Unlike a 502 Bad Gateway, the problem is normally in Nginx or the filesystem, not in an app behind it.

Not running Nginx, or only visiting a site that shows this error? Read 403 Forbidden: what it means and how to fix it.

Step 1: Check the Error Log

sudo tail -n 30 /var/log/nginx/error.log

The message tells you which cause you have:

Error log messageCause
directory index of "/var/www/site/" is forbiddenNo index file (Cause 1)
open() "/var/www/site/index.html" failed (13: Permission denied)File or folder permissions, or SELinux (Causes 2, 3, 5)
access forbidden by ruleA deny rule in your config (Cause 4)
Nothing loggedThe 403 probably comes from your app, a WAF or Cloudflare (Cause 6)

Cause 1: No Index File in the Directory

When you request a folder (like /), Nginx looks for the files listed in the index directive. If none exist and autoindex is off (the default), it returns 403. Fix it by making sure the file exists and is listed:

ls -la /var/www/site/

# in the server block
root /var/www/site;
index index.html index.php;

For PHP sites the most common version of this bug is a server block that lists only index.html, so index.php is never tried.

Cause 2: File Permissions

The Nginx worker runs as www-data on Ubuntu/Debian and nginx on RHEL, AlmaLinux, Rocky and Oracle Linux. It needs read permission on files. A safe standard for a static site:

sudo find /var/www/site -type d -exec chmod 755 {} \;
sudo find /var/www/site -type f -exec chmod 644 {} \;

Avoid chmod 777. It hides the real problem and lets any process on the server change your site.

Cause 3: A Parent Directory Blocks Access

This is the one people miss. Nginx needs execute (x) permission on every directory in the path, not just the last one. Serving from a home folder is the classic trap, because /home/user is often 750:

namei -l /home/user/site/index.html

Any line without x for "others" (or for the Nginx group) breaks access. Either move the site to /var/www (recommended) or grant traverse access: chmod o+x /home/user.

Cause 4: A deny Rule in the Config

Look for rules that block the request:

sudo nginx -T | grep -n -E "deny|allow"

A deny all; in a broad location block, or an allow list that does not include your IP, returns 403 with "access forbidden by rule" in the log. Remember that Nginx ignores .htaccess files, so rules copied from Apache have to be rewritten as Nginx config.

Cause 5: SELinux (RHEL, AlmaLinux, Rocky, Oracle Linux)

If permissions look correct but you still get "Permission denied", SELinux may be blocking Nginx from files that do not carry the web content label:

getenforce
ls -Z /var/www/site

sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/site(/.*)?"
sudo restorecon -Rv /var/www/site

Files created in a home folder and then moved keep their old label, which is why mv often triggers this while cp does not.

Cause 6: The 403 Is Not From Nginx

If nothing appears in the Nginx error log, something else is refusing the request: your application (for example a WordPress security plugin), a firewall such as ModSecurity, or Cloudflare's WAF. Check the response headers:

curl -I https://example.com/path

A server: cloudflare header with a Cloudflare-branded page means the block is at Cloudflare; check Security > Events in the dashboard.

Test and Reload

sudo nginx -t && sudo systemctl reload nginx

For other status codes, see common Nginx errors and how to fix them.

Frequently Asked Questions

What does 403 Forbidden nginx mean?
Nginx found the requested path but is not allowed to serve it, usually because of a missing index file, file or folder permissions, a deny rule, or SELinux.

How do I fix 403 Forbidden in Nginx on Ubuntu?
Read /var/log/nginx/error.log. If it says the directory index is forbidden, add an index file. If it says permission denied, give www-data read access to files and execute access to every parent folder.

Should I use chmod 777 to fix a 403?
No. Use 755 for folders and 644 for files. 777 lets any user or compromised process on the server modify your site.

Why do I get 403 for index.php but not index.html?
The index directive probably lists only index.html, or PHP is not configured in that server block. Add index.php and a location ~ \.php$ block that passes requests to PHP-FPM.

Is 403 the same as 401?
No. 401 means you must log in; 403 means the server will not serve the resource even if you are logged in.

Rather Not Debug Nginx at 2 AM?

Every error in this guide is something a managed host fixes for you. RackUp IT managed hosting runs a tuned Nginx, PHP and caching stack with monitoring, backups and SSL handled, so you can spend your time on the site instead of the server.

← Previous ArticleVercel Alternatives for Next.js: 7 Options Compared (2026)Next Article →404 Not Found in Nginx: Why It Happens and How to Fix It
Interactive 60-Second Tool

Unsure Which Cloud Hosting Plan Fits Your Site?

Answer 4 quick diagnostic questions to estimate the server CPU, RAM and storage you need with transparent pricing.

Free Migration 99.9% Uptime Target
Calculate My Hosting Build
Alex Vance
Written ByAlex Vance

Cloud Infrastructure Engineer.

99.9% Uptime Target

RackUp IT - View Cloud Hosting Plans

View Hosting Plans

View Hosting Plans

CONTENTS

  • 403 Forbidden in Nginx: 6 Causes and How to Fix Each One
  • Step 1: Check the Error Log
  • Cause 1: No Index File in the Directory
  • Cause 2: File Permissions
  • Cause 3: A Parent Directory Blocks Access
  • Cause 4: A deny Rule in the Config
  • Cause 5: SELinux (RHEL, AlmaLinux, Rocky, Oracle Linux)
  • Cause 6: The 403 Is Not From Nginx
  • Test and Reload
  • Frequently Asked Questions
  • Rather Not Debug Nginx at 2 AM?

Categories

  • VPS Hosting
  • DevOps & Tutorials
  • WordPress Hosting
  • Cloud Hosting
  • Server Stack
  • Networking & Security
  • Web Hosting / Managed Cloud
  • E-Commerce
  • Hosting & SEO
  • Hosting Benchmarks
  • Cloud Backup & DevOps
  • Managed VPS

Recent Posts

  • Vultr Alternatives in 2026: VPS Hosting for Developers Compared
  • Docker Port Mapping Explained: -p, EXPOSE and Compose ports
  • Bluehost Alternatives (2026): WordPress Hosting Without the Renewal Price Jump

Tags

Nginx403 ForbiddenTroubleshootingLinux PermissionsSELinuxVPS Hosting

Related Posts

Vultr alternatives coverVPS Hosting
Nov 27, 2026

Vultr Alternatives in 2026: VPS Hosting for Developers Compared

Vultr's Regular Performance prices compared with DigitalOcean, Linode, Hetzner and a fixed-plan VPS at the 8 GB size, plus when container hosting fits better.

Read Article →
What is a VPS? Virtual private servers explainedVPS Hosting
Nov 20, 2026

What Is a VPS? Virtual Private Servers Explained

A VPS (virtual private server) is a virtual machine with its own operating system, resources and root access. How it works, uses, and when you need one.

Read Article →
Linode alternatives coverVPS Hosting
Nov 19, 2026

Linode (Akamai) Alternatives in 2026: VPS Hosting Compared

Linode's shared CPU prices from Akamai's own API, compared with DigitalOcean, Vultr and a fixed-plan VPS, plus when container hosting makes more sense.

Read Article →
Logo

Expert Web & App Development, UI/UX Design, Branding, and Consulting to scale your business.

Company

  • About Us
  • Blog
  • Contact
  • Our Team
  • Careers

Services

  • Web Development
  • App Development
  • UI/UX Design
  • Consulting
  • Managed WordPress VPS
  • Website Speed Test

Subscribe to our newsletter

We accept
  • bKash
  • Nagad
  • Rocket
  • Upay
  • CellFin
  • Meghna Pay
  • OK Wallet
  • Tap
  • mCash
  • DBBL Nexus
  • Visa
  • Mastercard
  • American Express
  • Crypto
Pay with Visa, Mastercard, American Express, DBBL Nexus, CellFin, Rocket, bKash, Tap, Meghna Pay, Nagad, mCash, Upay and OK Wallet. Verified by EPS

© 2026 Rackup IT Solution. All rights reserved.

Privacy PolicyTerms of Service