What 403 Forbidden Means
The server received the request, knows what is being asked for, and decided not to serve it. That is the difference from 401 Unauthorized, where sending valid credentials would help; with 403 the server refuses even if it knows who you are, and repeating the request does not change that. The two are compared in 401 vs 403.
What Visitors Can Try
- Check the address: a folder address with no page at the end often returns 403.
- Clear the site's cookies and reload, or open a private window.
- Switch off a VPN or proxy: some sites refuse addresses from VPN networks.
- Try another network, such as a mobile connection, in case your address is blocked.
If none of this helps, contact the site; the rule is on their server.
Step 1: Reproduce It and Read the Log
curl -I https://example.com/page.html
sudo tail -n 30 /var/log/nginx/error.log
On Apache the log is /var/log/apache2/error.log on Debian and Ubuntu and /var/log/httpd/error_log on AlmaLinux and Rocky Linux. The line for the request says whether it was a file permission, a directory listing, or a configuration rule.
Step 2: File Permissions and Ownership
The web server user (www-data on Debian and Ubuntu, nginx or apache on AlmaLinux and Rocky Linux) must be able to read the file and to enter every directory above it. namei shows each step of the path:
namei -l /var/www/example.com/public/index.html
Directories need 755 and files 644 in most setups:
sudo find /var/www/example.com -type d -exec chmod 755 {} +
sudo find /var/www/example.com -type f -exec chmod 644 {} +
A site kept inside a home directory often fails here, because home directories are usually closed to other users. Never use 777 as the fix; chmod 777 explains why. Ownership changes are covered in chown recursive.
Step 3: Missing Index File
When the address points to a folder, the server looks for an index file such as index.html or index.php. If none exists and directory listing is off, the answer is 403. Check that the file exists and that it is named in the configuration: the index directive in Nginx, DirectoryIndex in Apache. Turning listing on is rarely the right fix.
Step 4: Deny Rules
| Server | Rule that refuses |
|---|---|
| Apache | Require all denied |
| Apache | Require ip 203.0.113.0/24 |
| Nginx | deny all; |
| Nginx | allow then deny |
Search the configuration and any .htaccess file on the path:
sudo grep -rn "deny\|Require" /etc/nginx/ /etc/apache2/ /etc/httpd/ /var/www/example.com/ 2>/dev/null
How .htaccess files apply to folders is in .htaccess file, and the Nginx-specific cases in 403 Forbidden in Nginx.
Step 5: Blocks Above the Web Server
A packet firewall such as ufw or firewalld drops or rejects connections; it does not send a 403. A 403 comes from something that speaks HTTP: a web application firewall module, a security plugin in the application, or a firewall rule at a CDN. Check their logs for the visitor's address and the rule that matched.
Step 6: SELinux on AlmaLinux and Rocky Linux
SELinux lets the web server read only files labeled for web content. Files moved with mv from a home directory keep their old label. Check and restore the labels:
ls -Z /var/www/example.com/public/
sudo restorecon -Rv /var/www/example.com
For a site outside /var/www, restorecon alone does not help, because the policy has no web label for that path. Add a rule first, then apply it:
sudo semanage fcontext -a -t httpd_sys_content_t "/srv/example.com(/.*)?"
sudo restorecon -Rv /srv/example.com
Background is in what is SELinux.