HTTP 403 Forbidden

HTTP 403 Forbidden: causes, permission checks, nginx rules and the difference from 401 and 404, for visitors and owners.

loading HTTP 403 Forbidden
About this tool

403 Forbidden: what it means

The server understood the request and refuses to carry it out. Unlike 401, the problem is not that the server does not know who you are: even with the right identity, this address is not for you, or the server is configured to deny it. Repeating the same request will not change the answer.

The code belongs to the 4xx class and its official name is "Forbidden". The page opens the status code list on 403, so you can compare it with its neighbours.

What the response looks like

HTTP/1.1 403 Forbidden
Content-Type: text/html; charset=utf-8
Content-Length: 153

Common causes

  • File or folder permissions the web server cannot read: the worker user needs execute on every directory of the path and read on the file.
  • A directory with no index file while directory listing is off.
  • An IP, country or user agent blocked by a firewall, a WAF or a rule such as Cloudflare's.
  • A signed or temporary URL that expired, common with object storage such as S3.
  • A logged-in user whose role does not include the action, or a request without the CSRF token.

How to fix it

If you are a visitor

  • Sign in with the account that has access, or ask the owner to grant it.
  • If you reached the page from an old bookmark, open the site's home page and navigate from there.
  • If a VPN or proxy is on, turn it off and try again: many sites block those ranges.

If you run the site or the API

  • Run namei -l on the full path of the file to see the permission of every directory down to it.
  • Set directories to 755 and files to 644 and make the web server user the owner or in the group.
  • Read the error log: nginx writes "permission denied" or "access forbidden by rule" with the path.
  • Check allow and deny rules, the WAF events and, for object storage, the bucket policy and the URL expiry.

Snippets to copy

Find the directory that blocks the path

namei -l /var/www/site/public/index.html
# the first line without "x" for the web server user is the culprit
sudo chmod 755 /var/www/site /var/www/site/public
sudo chmod 644 /var/www/site/public/index.html

nginx: deny by IP, allow the rest

location /admin/ {
    allow 203.0.113.10;
    deny  all;
}

Codes it is confused with

CodeDifference
401 UnauthorizedThe server does not know who you are: send valid credentials.
404 Not FoundNothing at that address; some sites answer 404 instead of 403 to hide a resource.
405 Method Not AllowedThe path exists but not for this method (POST on a read-only route).
451 Unavailable For Legal ReasonsBlocked for legal reasons.

Caching, retries and search engines

For crawlers a 403 means "do not index this". It is the right answer for private areas; it is the wrong one when a firewall rule blocks Googlebot by accident, which shows up as pages dropping out of the index.

Look up other status codes

  1. Open the list and type a number (404) or a word (timeout) in the search box.
  2. Read the description of the code and copy "403 Forbidden" with the button on its card.
  3. Use the # button to copy a link straight to that code.

Frequently asked questions

What is the difference between 401 and 403?

401 means unauthenticated: the server wants credentials. 403 means the server knows the request and still refuses it, so logging in again usually does not help.

Why do I get 403 on files I just uploaded?

Uploads often arrive owned by another user, or with mode 600, so the web server cannot read them. Fix the owner and set 644 for files and 755 for folders.

Can I fix a 403 as a visitor?

Only when the cause is on your side: an expired session, a VPN range that is blocked or a wrong account. Otherwise it is the site owner's configuration.

Report a problem