HTTP error reference

403 Forbidden

A 403 Forbidden means the server understood the request and refuses to fulfil it. Unlike a 401, logging in will not help: the server, a firewall or a security rule has decided this request is not allowed.

If you are visiting the site

Check the address is right and you are logged in if the page needs it. If you were blocked by a security service such as Cloudflare, the error page usually shows a reference number you can send to the site owner.

Common causes

File permissions

The web server’s user cannot read the file or folder. Typical safe settings are 755 for folders and 644 for files.

No index file

You requested a folder with no index.html or index.php, and directory listing is off. Nginx logs “directory index of … is forbidden”.

Access rules

Apache “Require all denied” or deny rules in .htaccess, Nginx “deny” lines, or an IP allow-list that does not include you.

A firewall or security service

A web application firewall, ModSecurity, a security plugin or Cloudflare’s rules blocked the request because it looked suspicious.

Hotlink protection

Images or files requested from another site are blocked on purpose.

How to fix it

Find who refused

  • Check whether the 403 page comes from your application, the web server, or a security service such as Cloudflare. Each logs the block in a different place.

Permissions and files

  • Fix ownership and permissions so the web server user can read the site files. Never use 777: it lets any process change your site.
  • Make sure the document root has an index file and points at the right folder after a deployment.

403 Forbidden on Nginx

  • Read the Nginx error log. “directory index of … is forbidden” means the folder has no index file, or the index directive does not list it (for example index.php is missing from it).
  • “open() … failed (13: Permission denied)” means the Nginx worker user cannot read the file. It also needs execute permission on every parent folder, not just the file itself.
  • Check root points at the right folder, and look for deny all, allow lists or auth rules in the matching location block. Run nginx -t before reloading.

On Ubuntu: nginx/1.18.0 or nginx/1.24.0

  • The version line means Ubuntu’s own Nginx package: 1.18.0 on Ubuntu 20.04 and 22.04, 1.24.0 on Ubuntu 24.04. Its error log is /var/log/nginx/error.log; read the last lines with sudo tail -n 50.
  • Ubuntu’s default site, /etc/nginx/sites-enabled/default, serves /var/www/html and its index line lists index.html, index.htm and index.nginx-debian.html but not index.php. A PHP site with no index.html returns 403 until you add index.php to that line.
  • Nginx runs as www-data. Run namei -l on the full path to your index file: every folder on the way needs execute permission for www-data. Since Ubuntu 21.04 new home folders are private (750), so a site under /home/username is unreadable to Nginx by default.
  • Test with sudo nginx -t, then sudo systemctl reload nginx. To stop advertising the version, add server_tokens off; to the http block. It does not fix the 403, but there is no reason to show it.

Apache

  • Review Require, Deny and Allow rules in the site configuration and .htaccess files. Apache logs the rule that refused the request in its error log.

WordPress

  • If wp-admin or one page returns 403, check your security plugin’s log, then disable plugins by renaming the wp-content/plugins folder over SFTP to see if the error clears.
  • Replace .htaccess with WordPress’s default rules (save Settings → Permalinks to regenerate it), and ask your host whether their firewall or ModSecurity blocked the request.

Cloudflare and firewalls

  • Look up the block in Cloudflare’s Security Events, or your firewall’s log, and adjust the specific rule rather than switching protection off.

Quick checklist

  1. Identify whether the refusal came from the application, proxy or firewall.

  2. Check account permissions and access rules.

  3. Avoid disabling access controls or granting broad file permissions as a workaround.

Questions about 403 errors

What is the difference between 401 and 403?

A 401 means the server does not know who you are yet, so logging in may help. A 403 means it knows, or does not care, and still says no.

Why do I get a 403 on my own WordPress site?

Usually a security plugin, a firewall rule or a permissions change after moving the site. Check the security plugin’s log first.

What does “403 Forbidden nginx/1.18.0 (Ubuntu)” mean?

The site runs on Nginx and Nginx refused the request. The version line only names the server software: 1.18.0 is the Nginx that Ubuntu 20.04 and 22.04 ship. The cause is in Nginx’s error log, usually a missing index file or file permissions.

Should I set permissions to 777 to fix it?

No. It may hide the error, but it lets anything on the server change your files. Fix ownership instead.

Use the guided checklist