Networking

How to Fix 403 Forbidden Error: Causes and Fixes

To fix a 403 Forbidden error as a visitor, check that the URL is correct, reload the page, clear that site's cookies, turn off any VPN or proxy, and sign in with an account that has access. If you own the site, the cause is almost always file permissions, a missing index file, or a server or firewall rule that denies the request.

A 403 is the server saying "I understood you, and no." That is different from a page that does not exist or a login that failed, so the fix depends on which side you are on. The sections below start with what a visitor can try, then cover the server-side causes.

What a 403 Forbidden error means

MDN describes 403 Forbidden as a client error response meaning the server understood the request but refused to process it. RFC 9110 gives the same definition: the server understood the request but refuses to fulfill it. The server may explain why in the response body, but it does not have to.

Browsers and servers word the message differently. Common variants include 403 Forbidden, HTTP Error 403.1 - Forbidden, Access Denied, and You don't have permission to access this resource. The status code underneath is the same.

MDN also says a client that gets a 403 should expect that repeating the identical request fails the same way. That is why plain refreshing rarely helps and why the fixes below all change something about the request or the server.

How to fix a 403 error as a visitor

Work through these in order. Each one changes something the server might be judging you on.

  1. Check the URL. A typo, a missing file name, or a trailing path that points at a folder instead of a page can all produce a 403. Try the site's home page, then navigate to the page from there.
  2. Reload the page. Use Ctrl+F5 (Windows, Linux) or Cmd+Shift+R (macOS) to bypass the cached copy. A cached 403 can persist after the cause is gone.
  3. Clear cookies for that site only. A stale or corrupted session cookie can make the server treat you as someone without access. Delete cookies for the one domain in your browser's site settings, then sign in again.
  4. Sign in, or switch accounts. Many sites return 403 for a page that needs a role you do not have. MDN's own example is a DELETE request with a valid token that gets 403 because the caller lacks the admin role. Authentication was fine; authorization was not.
  5. Turn off your VPN or proxy. Sites and CDNs can block address ranges they associate with abuse or with a country they do not serve. Try the page from another network, such as your phone's mobile data, to see whether the address is the problem.
  6. Try a private window or another browser. This rules out extensions and saved site data in one step.
  7. Contact the site owner. If a security service blocked you, the owner is the only one who can lift it.

Cloudflare "Error 1020 Access denied"

If the page shows Cloudflare's Error 1020, Cloudflare's documentation says it is returned with HTTP 403 and means a security rule set up by the site owner blocked your request. As a visitor you generally cannot fix it. The documented step is to send the owner a screenshot of the error, including the Ray ID shown on the page, so they can find the rule in their Security Events log.

How to fix a 403 error on your own site

If the 403 comes from a site you run, find the cause in the server's error log first. Guessing at permissions without reading the log wastes time, because the log usually names the file or rule involved.

Missing index file or directory listing

A request that ends in / asks the server for a directory's default page. In nginx, the index directive defines which files are used, and its default is index index.html;. If none of those files exist, nginx hands the request to the autoindex module, which produces a directory listing only when you turn it on. The autoindex directive is off by default. Either add the missing index file, or, if you really want a listing, enable it for that location:

location /downloads/ {
    autoindex on;
}

Check the nginx error log for the exact reason before changing anything, since a 403 can also come from file permissions or a deny rule.

File and directory permissions

The web server runs as a particular user, and that user needs read access to each file and execute (search) access on every directory in the path. On Linux you can check the whole path in one command, and the user and group shown are the ones to compare against the server's account:

namei -l /var/www/example/public/index.html

Typical safe values are directories at 755 and files at 644, owned by a user the web server can read as. Avoid 777, which gives every account write access. The chmod guide explains how to read those modes, and the status codes overview covers the other 4xx codes.

Apache access rules

Apache 2.4 controls access with Require directives. A visitor blocked by a rule such as Require not ip inside a RequireAll block cannot see the content it covers, and the response is 403. The Apache documentation also shows that the [F] flag on a RewriteRule returns 403. Look in .htaccess and the virtual host for these. The old Order, Allow and Deny directives from mod_access_compat are deprecated, and mixing them with Require in one configuration is a common source of surprising denials.

<RequireAll>
    Require all granted
    Require not ip 192.168.205
</RequireAll>

The Apache documentation warns that access control by User-Agent is unreliable, because the header can be set to anything. Do not rely on it for security, and check that it is not blocking legitimate clients by accident.

Firewall, WAF and CDN rules

A web application firewall, a CDN security rule, a country block or a rate limit can all return 403 before the request reaches your application. If your own server logs show no matching request, the block is happening in front of it. Search the CDN or firewall event log for the visitor's IP address or the request ID.

API calls and tokens

For an API, a 403 usually means the credential was accepted but is not allowed to do this action. Compare the token's scopes or roles with what the endpoint requires. A 401 is the code for a missing or invalid credential, so a 403 with a valid token points at permissions, not at the login. The CORS error guide covers the browser-side block that looks similar but is a different mechanism.

When the server shows 404 instead

RFC 9110 says a server that does not want to reveal a forbidden resource's existence may answer 404 instead, and MDN repeats this. If you are sure a page exists but get "Not Found", check that you are signed in as the right account before assuming the file is gone.

If the 403 keeps coming back

Test the same URL from a different network and a different browser. If it works there, the cause is your address, cookies or extensions. If it fails everywhere, the cause is on the server. If you own it, read the error log, find the file path or rule named in the entry, and fix that one thing before changing anything else.

Frequently asked questions

What is the difference between 401 and 403?
A 401 means the request lacks valid authentication, so logging in can fix it. A 403 means the server understood the request and refuses it anyway, so authenticating again usually makes no difference. MDN describes 403 as similar to 401 except that re-authenticating does not help.
Can I fix a 403 error on a site I do not own?
Only partly. You can check the URL, clear that site's cookies, turn off a VPN or proxy and sign in with an account that has access. If the server's rules block you, only the site owner can change them.
Why do I get a 404 instead of a 403 for a page that exists?
The HTTP specification lets a server answer 404 instead of 403 when it does not want to reveal that a restricted resource exists. A 404 for a page you know exists can therefore be a permission problem.
Does a 403 mean I have been banned?
Not necessarily. A 403 can come from a missing file permission, a missing index file, a firewall rule, a country or IP block, or a missing role. Only the server's logs say which rule fired.

Sources