403 Forbidden Error: Causes and How to Fix It

403 Forbidden Error: Causes and How to Fix It

  1. Home
  2. Blogs
  3. 403 Forbidden Error: Causes and How to Fix It

A 403 Forbidden error means the server understood the request but refuses to fulfil it: access to the page or file is not allowed. Unlike 5xx errors, the server is working here — it has simply decided this resource must not be shown. Here is why that happens and how to find the cause on your own site.

How 403 Differs from 401 and 404

Code What it means What usually helps
401 Unauthorized Authentication is required: login, password or token Sign in or send valid credentials
403 Forbidden Access is denied, even if you are authenticated Fix permissions, server rules or security settings
404 Not Found Nothing exists at this address Check the URL, links and redirects

If your site returns 5xx errors instead, see our guides to the 502 Bad Gateway error and to errors 504 and 524.

What to Do as a Visitor

  • Reload the page and check the address: a 403 is sometimes returned when you open a folder instead of a page.
  • Clear the site's cookies and cache or open it in a private window.
  • Turn off your VPN or proxy: some sites block IPs of whole networks or countries.
  • If the error stays, contact the site owner — the problem is almost always on their side.

Common Causes on the Site's Side

1. Wrong File and Folder Permissions

The web server runs as a separate user (www-data on Ubuntu and Debian). If it cannot read a file or enter a folder, visitors get a 403. Typical permissions are 755 for folders and 644 for files, owned by the web server user:

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

Do not set 777 "just to make it work": it makes files writable by everyone and opens a security hole.

2. Missing Index File

If a folder has no index.php or index.html and directory listing is disabled (as it should be), the server returns 403. Check that the file exists and that your Nginx config lists it:

server {
    root /var/www/example.com;
    index index.php index.html;
    # ...
}

3. Deny Rules in Nginx or .htaccess

deny all rules are useful for service files, but an overly broad pattern can block normal pages too. In Nginx, review your location blocks:

location ~ /\. {
    deny all;
}
# check that no broad rule like this blocks your real pages:
# location / { deny all; }

In Apache, check .htaccess and the site config. After moving to Apache 2.4, old 2.2 syntax often causes 403:

# Apache 2.4
Require all granted

# old Apache 2.2 syntax that may cause 403 on 2.4:
# Order deny,allow
# Deny from all

4. Security Plugins and WordPress

Security plugins (firewalls, login limiters, country blocking) can add their own rules to .htaccess or block IPs. Temporarily rename the plugin folder over SSH or SFTP and see whether the error disappears. If it does, adjust the plugin rules rather than removing protection altogether.

5. Cloudflare, WAF and IP Blocking

The 403 may come not from your server but from Cloudflare or another WAF — for example, because of country rules, Bot Fight Mode or a suspicious IP. The sign is an error page with the Cloudflare logo and a Ray ID. Check Security → Events to see which rule fired.

6. SELinux and Non-Standard Paths

On CentOS, AlmaLinux and Rocky Linux, SELinux can prevent the web server from reading files outside standard folders even with correct permissions. Check the file context (ls -Z) and the audit log.

How to Find the Exact Cause in the Logs

The web server error log almost always names the cause directly: permission denied, directory index of ... is forbidden or access forbidden by rule.

sudo tail -n 50 /var/log/nginx/error.log
sudo tail -n 50 /var/log/apache2/error.log

After any change, test the config and reload the web server:

sudo nginx -t && sudo systemctl reload nginx
# or for Apache
sudo apachectl configtest && sudo systemctl reload apache2

Quick Checklist

  1. Is the error returned by your server or by Cloudflare/WAF?
  2. What does error.log say at the moment of the request?
  3. Are permissions 755/644 and is the owner the web server user?
  4. Does the index file exist and is it listed in the config?
  5. Are there broad deny rules in Nginx or .htaccess?
  6. Is a security plugin or SELinux blocking the request?

On a PSB Hosting VPS you have root access to every log and config, so a 403 can usually be found and fixed in minutes. If your site grows and the load increases, have a look at Hi-CPU VPS. More error breakdowns and guides are in the PSB Hosting blog.

Related articles

9HTTP: Global Proxy IP Solutions for Cross-Border Business and AI Applications

9HTTP: Global Proxy IP Solutions for Cross-Border Business and AI Applications

Partner content: 9HTTP. As businesses expand into global markets, data collection, market research, SEO monitoring, ad verification, and AI-related applications require increasingly diverse network e

504 Gateway Timeout and Error 524: Causes and How to Fix Them

504 Gateway Timeout and Error 524: Causes and How to Fix Them

Errors 504 and 524 mean essentially the same thing: the server took too long to respond and the intermediary stopped waiting. The difference is who gave up waiting — your web server or Cloudflar

How to Automate CAPTCHA Solving on a VPS with CaptchaAI

How to Automate CAPTCHA Solving on a VPS with CaptchaAI

Partner content. Prepared by the CaptchaAI team. Moving an automation project to a VPS solves one problem: the application no longer depends on someone keeping a laptop open. But a server that sta

VPN vs VPS: What's the Difference and Which One Do You Need?

VPN vs VPS: What's the Difference and Which One Do You Need?

VPN and VPS are easy to mix up: the abbreviations look alike, and both come up in conversations about servers and security. In reality they are completely different things. Let's look at the differenc

Mobile Proxies on a VPS: Building Reliable Workflows for Social Media and Automation

Mobile Proxies on a VPS: Building Reliable Workflows for Social Media and Automation

Teams that manage dozens of social media accounts or run automation eventually arrive at the same setup: a server that runs 24/7 and mobile proxies that carry that traffic to the internet. Here is how

500 Internal Server Error: Causes and How to Fix It

500 Internal Server Error: Causes and How to Fix It

500 Internal Server Error means something went wrong on the server — but the server won't tell the visitor what. It's the least informative error: it has dozens of possible causes. The good news

Buysellacc.com: a Platform for MMO Accounts and Digital Services

Buysellacc.com: a Platform for MMO Accounts and Digital Services

Partner content. Prepared by the Buysellacc team. Buysellacc.com is a platform with an automated system for MMO accounts and digital services. It works for individuals, collaborators, resellers and b

How to Connect to a Server via SSH: Windows, macOS and Linux Step by Step

How to Connect to a Server via SSH: Windows, macOS and Linux Step by Step

SSH is the standard way to manage a VPS or dedicated server: you use it to install software, edit configs, read logs and restart services. This guide shows how to connect to a server via SSH from Wind

Money Safe Review: a Service for Manually Built White Pages for Media Buyers

Money Safe Review: a Service for Manually Built White Pages for Media Buyers

Partner content. Prepared by the Money Safe team. In affiliate marketing, there haven’t been any one-size-fits-all solutions that guarantee passing moderation for quite some time. The algorithm

Telegram