# 403 Forbidden in nginx

> Trace an nginx 403 to its cause: allow/deny rules, auth_request, referer checks, missing index files or worker permissions. Includes config examples.

Canonical: https://scaplet.com/errors/http/403/nginx

Guide Error · HTTP status codes

Trace an nginx 403 to its cause: allow/deny rules, auth_request, referer checks, missing index files or worker permissions. Includes config examples.

5 min

read

11

sources

Oct 23, 2026

updated

Scaplet Editorial Team

author

403 4xx · Client error

The short answer

An nginx 403 means nginx, or an app behind it, refused the request. In nginx itself the usual causes are allow and deny rules, an auth_request subrequest answering 403, a referer check that returns 403, a directory with no index file and autoindex off, or files the worker user can't read. Read the error log for the line that names the cause.

1. [Why does nginx return 403?](#why-does-nginx-return-403)
2. [Access rules: allow, deny and satisfy](#access-rules-allow-deny-and-satisfy)
3. [Index files, autoindex and file permissions](#index-files-autoindex-and-file-permissions)
4. [Find the cause in two minutes](#find-the-cause-in-two-minutes)
5. [What it does to SEO](#what-it-does-to-seo)

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F403%2Fnginx%20(%22403%20Forbidden%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F403%2Fnginx%20(%22403%20Forbidden%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F403%2Fnginx%20(%22403%20Forbidden%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F403%2Fnginx%20(%22403%20Forbidden%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

_01_nginx causes of a 403 and where to look

## Why does nginx return 403?

A 403 means the server understood the request and refused it (see [403 Forbidden](/errors/http/403)). In nginx, the refusal is configured in a handful of places. Check them in this order, because the first ones are the most mechanical.

Cause

### allow and deny rules

What the nginx docs say

Rules are checked in sequence until the first match

What to check

The location block and its parents; the order of allow and deny; a final deny all

Cause

### Inherited access rules

What the nginx docs say

allow and deny are inherited from the previous level only if the current level defines none

What to check

A new allow or deny in a location silently replaces the server-level rules

Cause

### Address and password rules combined

What the nginx docs say

satisfy defaults to all, so every access module must allow the request

What to check

Add satisfy any if either an IP match or a password should be enough

Cause

### auth_request

What the nginx docs say

A subrequest answering 401 or 403 denies the access with that code

What to check

The auth service's response for this request

Cause

### Referer check

What the nginx docs say

The referer module example uses return 403 when $invalid_referer is set

What to check

valid_referers list; browsers may not send the Referer header

Cause

### No index file, autoindex off

What the nginx docs say

index defaults to index.html; autoindex defaults to off, and a request usually reaches it when no index file is found

What to check

The index directive, the file on disk, and whether you want a listing

Cause

### Worker user cannot read the files

What the nginx docs say

The user directive defines the credentials used by worker processes

What to check

The user and group in the main context against file and directory permissions

Cause

### The proxied application

What the nginx docs say

nginx passes the upstream's 403 on

What to check

The upstream's own logs

Every row comes from the nginx documentation for the named module, except the last, which is simply what a reverse proxy does with an upstream response. The error log usually names the check that refused the request. For a directory with no index file, nginx's source logs `directory index of "/path/" is forbidden`.

**A 403 from the app and a 403 from nginx look the same**Request the upstream directly, bypassing nginx. If it also returns 403, the application is the source and nginx is only relaying it.

_02_Check it

## Access rules: allow, deny and satisfy

The access module limits access to certain client addresses. Its own example shows the rule order that matters:

Per the docs, access is allowed only for those networks, excluding 192.168.1.1. Put the specific rules first and deny all last. If you reach the end with deny all, anyone not listed is refused.

When you protect a path by both address and password, the satisfy directive decides how they combine. The default is all, so a visitor must pass every check. This example allows a visitor who either comes from the allowed address or supplies a valid password:

satisfy any: IP match or password

```
location / { satisfy any; allow 192.168.1.0/32; deny all; auth_basic "closed site"; auth_basic_user_file conf/htpasswd; }
```

**A password failure is a 401, not a 403**The auth_basic module answers with a 401 and a WWW-Authenticate: Basic challenge when credentials are missing or wrong (see ngx_http_auth_basic_module.c in nginx's source). If your visitors see 403 where you expect a login prompt, an address rule is refusing them before authentication gets a chance. See [401 Unauthorized](/errors/http/401).

allow and deny are checked top to bottom

```
location / { deny 192.168.1.1; allow 192.168.1.0/24; allow 10.1.1.0/16; allow 2001:0db8::/32; deny all; }
```

_03_Explained

## Index files, autoindex and file permissions

A request ending in a slash is handled by the index module, which looks for the files named in index (default index.html). The nginx docs say a request usually goes on to the autoindex module when no index file is found. That module produces a directory listing, but autoindex is off by default. With no index file and the default settings, no handler serves the request, and nginx's source returns 403 and logs `directory index of "/path/" is forbidden`. Either add the index file or turn the listing on for that location only:

Serve a listing for one location

```
location /downloads/ { autoindex on; }
```

The index module also does an internal redirect, so the request can be processed in a different location from the one you expected. A `location = /` block with `index index.html` sends "/" to the second location as "/index.html". Check the location that finally handles the request, not only the first.

File permissions come last. When nginx can't open a file because of permissions, it returns 403 and the error log line ends in `(13: Permission denied)` on Linux. Worker processes run as the user set by the user directive (the default is nobody). That account needs execute permission on every directory in the path and read permission on the file. Test it as that user:

Check the path as the worker user

```
# Show owner and mode for every component of the path namei -l /var/www/example/index.html # Try to read the file as the worker user (replace www-data) sudo -u www-data cat /var/www/example/index.html
```

namei is part of util-linux; the account name varies by distribution. Look at the user line in nginx.conf for yours.

_04_How it works

## Find the cause in two minutes

1. 1

### Confirm nginx answered

Request the URL with a header dump and compare it to a direct request to the upstream. A 403 only through nginx is an nginx rule.
2. 2

### Read the error log

Open the file set by error_log in your configuration (default logs/error.log, level error). The lines above are logged at the error level, so the default setting shows them.
3. 3

### Match it to a row in the table

Access rule, auth_request, referer, index, or permissions. Change only that one.
4. 4

### Reload and retest as the real client

Reload nginx after the change, then retry with the same IP, Referer and credentials the failing client used.

You can also customize what visitors see. error_page 403 /forbidden.html serves a page of your choice, and the nginx docs show the same directive with a full URL, such as error_page 403 http://example.com/forbidden.html. That changes the page, not the cause.

_05_Explained

## What it does to SEO

Google treats every 4xx other than 429 the same way: the URL is dropped from the index if it was indexed. It also says that 401 and 403 have no effect on crawl rate, so don't use them to slow [Googlebot](/ai-crawlers/googlebot). If an allow or deny rule or a referer check is refusing crawlers, those pages leave the index. See [4xx errors](/seo-issues/4xx-errors). If the 403 comes from a CDN in front of nginx instead, see [403 Forbidden](/errors/http/403).

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ Why do I get 403 Forbidden on nginx for a directory?

The index module looks for an index file (default index.html). Without one, the request usually falls to the autoindex module, which is off by default, and nginx answers 403. Add the index file, set the index directive to the file you have, or enable autoindex for that location.

_02_ How do I fix an nginx 403 permission error?

Worker processes use the user and group set by the user directive. Make sure that account can read the file and traverse every directory above it, then check the error log for the line that names the cause.

_03_ What is the difference between nginx 401 and 403?

The auth_basic module returns 401 with a Basic challenge when credentials are missing or wrong. A 403 comes from refusals such as allow and deny rules, an auth_request subrequest returning 403, or a referer check using return 403.

_04_ Why does nginx return 403 after I added password protection?

satisfy defaults to all, so an address rule and a password must both pass. Add satisfy any if either one should be enough, and check that deny all isn't refusing the visitor first.

Sources · 11

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- rfc-editor.org
- nginx.org
- github.com
- google.com

1. 01 [RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html) rfc-editor.org · checked 2026-10-25
2. 02 [Module ngx_http_access_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_access_module.html) nginx.org · checked 2026-10-25
3. 03 [Module ngx_http_index_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_index_module.html) nginx.org · checked 2026-10-25
4. 04 [Module ngx_http_autoindex_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_autoindex_module.html) nginx.org · checked 2026-10-25
5. 05 [Core functionality (user directive) - nginx documentation](https://nginx.org/en/docs/ngx_core_module.html) nginx.org · checked 2026-10-25
6. 06 [Module ngx_http_core_module (satisfy) - nginx documentation](https://nginx.org/en/docs/http/ngx_http_core_module.html) nginx.org · checked 2026-10-25
7. 07 [Module ngx_http_auth_request_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_auth_request_module.html) nginx.org · checked 2026-10-25
8. 08 [Module ngx_http_referer_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_referer_module.html) nginx.org · checked 2026-10-25
9. 09 [Module ngx_http_auth_basic_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html) nginx.org · checked 2026-10-25
10. 10 [nginx source: ngx_http_core_module.c and ngx_http_auth_basic_module.c (GitHub)](https://github.com/nginx/nginx/blob/master/src/http/ngx_http_core_module.c) github.com · checked 2026-10-25
11. 11 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-10-25

## Keep learning

[All errors](/errors)

[Learn 403 Forbidden HTTP status codes](/errors/http/403) [Related 502 Bad Gateway in nginx HTTP status codes](/errors/http/502/nginx) [Read next HTTP 401 Unauthorized HTTP status codes](/errors/http/401) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 403 errors
[403 Forbidden in Django](/errors/http/403/django) [403 Forbidden in IIS](/errors/http/403/iis) [403 Forbidden in Laravel](/errors/http/403/laravel) [403 Forbidden in Spring Boot](/errors/http/403/spring-boot) [403 Forbidden in WordPress](/errors/http/403/wordpress)

More in 403 Forbidden
[403 Forbidden in Apache](/errors/http/403/apache) [403 Forbidden in Chrome](/errors/http/403/chrome) [403 Forbidden in Django](/errors/http/403/django) [403 Forbidden in IIS](/errors/http/403/iis) [403 Forbidden in Laravel](/errors/http/403/laravel) [403 Forbidden in nginx](/errors/http/403/nginx) [403 Forbidden in Spring Boot](/errors/http/403/spring-boot) [403 Forbidden in WordPress](/errors/http/403/wordpress) [403 Forbidden on Cloudflare](/errors/http/403/cloudflare) [403 Forbidden on CloudFront](/errors/http/403/cloudfront)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
