Talk to the NOC, IST hours — +91 75994 50220 support@bigdomainhost.com
Guide

How to fix a 403 Forbidden error

A 403 Forbidden is the server telling you it understood the request and is refusing it on purpose. This guide shows how to find which rule, permission or filter is responsible and how to fix it.

Short answer: A 403 Forbidden means the server understood the request but refuses to serve it. On your own site the usual causes are wrong file or folder permissions, a missing index file with directory listing off, a deny rule in .htaccess, an IP block, a WAF or Cloudflare rule, hotlink protection, a wrong document root or SELinux labels. The error log names the cause.

What a 403 Forbidden error means

A 403 Forbidden means the server received and understood the request but will not serve it. RFC 9110 defines it in those terms and adds that, if the request carried credentials, the server considers them insufficient. The block comes from a rule, permission or filter on the server or in front of it.

It is easy to confuse with two neighbouring codes:

CodeWhat the server is sayingTypical fix
401 UnauthorizedYou have not authenticated, or your credentials are invalid. The response must include a WWW-Authenticate header saying how to log in.Supply valid credentials
403 ForbiddenI know what you want and I refuse to serve it.Change the permission, rule or filter that blocks it
404 Not FoundNothing exists at this URL, or the server prefers not to say.Fix the path or the link

RFC 9110 also allows a server to answer 404 instead of 403 when it wants to hide that a forbidden resource exists, so a 404 on a private area can be a disguised 403.

Quick-fix checklist for site owners

  1. Check who sent the 403: curl -I https://example.com/page. The server: cloudflare header appears on every proxied response, so judge by the error page: Cloudflare branding means Cloudflare blocked it, no branding means your origin did.
  2. Read the web server error log at the time of the request: sudo tail -n 50 /var/log/apache2/error.log (Ubuntu and Debian), /var/log/httpd/error_log (AlmaLinux and Rocky) or /var/log/nginx/error.log.
  3. If the URL ends in a slash, confirm the folder has an index file such as index.php or index.html.
  4. Check permissions: folders 755, files 644, owned by the right user.
  5. Rename .htaccess to .htaccess.bak for a minute. If the page loads, the problem is a rule in that file. Rename it back straight away, because it usually holds your rewrite and redirect rules.
  6. Undo the last change: a security plugin, a new firewall rule, a migration or a moved document root.

Reading the error log

Apache 2.4 tags messages with an AH code. These are the ones that go with a 403:

Log message (shortened)Cause
AH01630: client denied by server configuration: /var/www/...A Require rule denies the request
AH01797: client denied by server configurationOld-style Order/Deny rules from mod_access_compat
AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directiveNo index file and directory listing is off
AH00035: access to /page denied (filesystem path '...') because search permissions are missing on a component of the pathA parent folder lacks execute permission
Symbolic link not allowed or link target not accessibleA symlink is not allowed by Options, or its target is unreadable
ModSecurity: Access denied with code 403A ModSecurity WAF rule matched

On Nginx, a missing index file with listing off logs directory index of "/var/www/html/" is forbidden, and a permission problem logs open() "..." failed (13: Permission denied).

Cause 1: file and folder permissions or ownership

The web server user (www-data on Ubuntu and Debian, apache or nginx on AlmaLinux) must be able to read each file and pass through every folder above it. One folder at 700 anywhere in the path is enough to block the whole site. Show the permissions of every component of the path:

namei -l /var/www/example.com/public/index.php

Then reset to the usual values and fix ownership:

sudo find /var/www/example.com -type d -exec chmod 755 {} \;
sudo find /var/www/example.com -type f -exec chmod 644 {} \;
sudo chown -R deploy:www-data /var/www/example.com

These commands are recursive, so run them on one site's folder only, never on /var/www or /. Replace deploy with the user who uploads your files, and www-data with apache or nginx on AlmaLinux and Rocky. Do not use 777; it makes files writable by every process on the server.

Cause 2: no index file and directory listing disabled

When a URL ends in a slash, the server looks for the files named in DirectoryIndex (Apache) or index (Nginx). If none exists and directory listing is off, the answer is 403. Listing is off in Apache when Options -Indexes is set, and in Nginx autoindex defaults to off.

The right fix is almost always to upload the missing index.php or index.html, or to correct the index list:

# Apache
DirectoryIndex index.php index.html

# Nginx
index index.php index.html;

Turn listing on (Options +Indexes or autoindex on;) only for a folder you deliberately want to publish as a file list, since it exposes every file in it.

Cause 3: deny rules in .htaccess or the server config

Apache 2.4 uses Require. A leftover Require all denied, or an old Deny from all, in .htaccess or a <Directory> block blocks everyone. Allow access explicitly:

<Directory "/var/www/example.com/public">
    Require all granted
</Directory>

Apache's upgrade notes advise against mixing old Order/Allow/Deny lines with Require in the same scope, because the results are hard to predict. Convert them all to Require. Test and reload with sudo apachectl configtest && sudo systemctl reload apache2 (httpd on AlmaLinux). In Nginx, look for deny all; in the matching location.

Cause 4: IP blocks

A rule such as Require not ip 203.0.113.0/24 inside <RequireAll>, an Nginx deny line or a security plugin's block list will forbid matching visitors. If your site sits behind Cloudflare, requests reach your server from Cloudflare addresses, so blocking a Cloudflare range at the origin produces a 403 for many unrelated visitors. Allow the published Cloudflare ranges and restore the real visitor IP with Apache mod_remoteip or the Nginx ngx_http_realip_module before writing IP rules.

Cause 5: ModSecurity or another WAF rule

A web application firewall returns 403 when a request looks like an attack, which can catch harmless form posts, admin actions or API calls. Find the rule ID in the error log or the ModSecurity audit log, then exclude that one rule for that one URL rather than turning the WAF off. On shared hosting you usually cannot edit WAF rules; send your host the URL, the time and your IP address.

Cause 6: Cloudflare 403 vs origin 403

Cloudflare's documentation draws the line on the error page itself. A 403 page without Cloudflare branding came from your origin server, so work through the causes on this page. A Cloudflare-branded 403 comes from Cloudflare's own features, such as WAF custom or managed rules, the security level, DDoS protection or Browser Integrity Check. Look up the request in Security Events (Analytics, then the Events tab, in the Cloudflare dashboard) to see which rule matched, then adjust or skip that rule.

Cause 7: hotlink protection

Hotlink protection refuses image or file requests whose Referer header names another site. A typical Apache rule ends in RewriteRule \.(jpe?g|png|gif|webp)$ - [F], where the [F] flag returns 403. If your own pages, a CDN subdomain or a new domain lose their images, add those hosts to the allowed list, and allow an empty Referer so direct visits and some apps still work.

Cause 8: wrong document root

If the DocumentRoot (Apache) or root (Nginx) points at an empty folder, a folder outside the allowed <Directory> blocks, or the project root instead of its public folder, you get a 403 even though the files are on disk. On Apache, sudo apachectl -S shows which virtual host file answers for your domain; check the DocumentRoot line in that file. On Nginx, run sudo nginx -T | grep -E "server_name|root".

Cause 9: SELinux on AlmaLinux and Rocky

With SELinux enforcing, the web server may only read files labelled for web content. Files moved (rather than copied) from a home folder, or a site placed in a custom path such as /data/www, keep the wrong label (the default policy already labels /var/www and /srv/www for web content), so permissions look correct but the server is still refused. Confirm and fix the label:

ls -Z /data/www/example.com
sudo ausearch -m avc -ts recent
sudo semanage fcontext -a -t httpd_sys_content_t "/data/www(/.*)?"
sudo restorecon -Rv /data/www

If semanage is missing, install it with sudo dnf install policycoreutils-python-utils. Folders the site must write to, such as an uploads folder, need httpd_sys_rw_content_t instead. Do not disable SELinux; relabelling is the narrow fix.

Visitor side vs site owner side

As a visitor, check the address, sign in if the page needs an account and turn off any VPN. If a Cloudflare page shows a Ray ID, send it to the site owner.

As the owner, start with the log line and the error page branding; together they tell you which of the causes above you have. After moving to a new host, check the document root, ownership and .htaccess first. If you see a redirect loop instead, read the ERR_TOO_MANY_REDIRECTS guide.

Fixing a 403 on Bigdomainhost

On Web & cPanel hosting and WordPress hosting, sites run on LiteSpeed in Mumbai, which reads Apache-style .htaccess rules, so the index file, permission and .htaccess checks above apply. Use the cPanel file manager to check them. These servers also run Imunify360 with a web application firewall; if you think it has blocked a legitimate request, call or WhatsApp +91 75994 50220 or email support@bigdomainhost.com with the URL, the time and your IP address.

On a Bigdomainhost KVM VPS you have full root access, so every command on this page works on the Ubuntu, Debian and AlmaLinux images, including the SELinux steps on AlmaLinux. The VPS documentation covers the console and firewall rules.

Sources (checked )

Answers

Frequently asked questions

Still unsure? Call +91 75994 50220 or write to support@bigdomainhost.com — a human replies in IST hours.

What does 403 Forbidden mean?

It means the server received and understood your request but refuses to serve it. The refusal comes from something on the server or in front of it, such as file permissions, an access rule in .htaccess, an IP block, a web application firewall or a Cloudflare rule. Repeating the same request usually gets the same answer until that rule or setting changes.

What is the difference between 401 and 403?

A 401 Unauthorized means you have not authenticated or your credentials are invalid, and the server sends a WWW-Authenticate header saying how to log in. A 403 Forbidden means the server will not serve the resource; if you did send credentials, it considers them insufficient, so logging in again with the same account will not help.

How do I fix 403 Forbidden on my website?

Read the web server error log first. Then check that every folder is 755 and every file 644 with the right owner, that the folder has an index file, and that .htaccess has no Require all denied or Deny from all rule. If the error page carries Cloudflare branding, check the Security Events view in Cloudflare instead.

Why do I get 403 Forbidden on a folder with no index file?

When a URL ends in a slash, the server looks for an index file such as index.php or index.html. If none exists and directory listing is disabled with Options -Indexes on Apache or autoindex off on Nginx, it returns 403. Upload the index file, or correct the DirectoryIndex or index directive.

Is a 403 Forbidden error my fault as a visitor?

Sometimes. Check the address, sign in if the page needs an account, and turn off any VPN or proxy, because shared VPN addresses are often blocked. If the error remains while other people can open the page, the site is blocking your IP or network, and only the site owner can change that.

Support that picks up the phone.

In IST hours, in Hindi or English, and WhatsApp replies fastest at any time. Sales, migration and emergencies all reach the same engineers. No offshore queue, no 48-hour first reply.

Need cPanel or WHM with the ports already sorted?

Web & cPanel hosting comes with cPanel ready to log in to, reseller hosting adds white-label WHM, and a KVM VPS can have cPanel & WHM pre-installed. Call +91 75994 50220 or email support@bigdomainhost.com.