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:
| Code | What the server is saying | Typical fix |
|---|---|---|
401 Unauthorized | You 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 Forbidden | I know what you want and I refuse to serve it. | Change the permission, rule or filter that blocks it |
404 Not Found | Nothing 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
- Check who sent the 403:
curl -I https://example.com/page. Theserver: cloudflareheader appears on every proxied response, so judge by the error page: Cloudflare branding means Cloudflare blocked it, no branding means your origin did. - 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. - If the URL ends in a slash, confirm the folder has an index file such as
index.phporindex.html. - Check permissions: folders
755, files644, owned by the right user. - Rename
.htaccessto.htaccess.bakfor 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. - 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 configuration | Old-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 directive | No index file and directory listing is off |
AH00035: access to /page denied (filesystem path '...') because search permissions are missing on a component of the path | A parent folder lacks execute permission |
Symbolic link not allowed or link target not accessible | A symlink is not allowed by Options, or its target is unreadable |
ModSecurity: Access denied with code 403 | A 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 )
- IETF: RFC 9110: HTTP Semantics, section 15.5.4 403 Forbidden
- Apache HTTP Server: Upgrading to 2.4 from 2.2: access control
- Apache HTTP Server: mod_authz_core
- nginx.org: Module ngx_http_autoindex_module
- Cloudflare Docs: Error 403
- MDN Web Docs: 403 Forbidden