> For the complete documentation index, see [llms.txt](https://learn.sitecove.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.sitecove.com/how-to-guides/web-hosting/troubleshooting-and-error-fixes/how-to-fix-403-404-and-502-errors.md).

# How to Fix 403, 404 & 502 Errors

Website errors can be frustrating for both users and website owners. Among the most common HTTP errors are **403 Forbidden**, **404 Not Found**, and **502 Bad Gateway**. Each of these errors indicates a different issue with the website. In this guide, we will discuss the causes and step-by-step solutions for fixing these errors.

***

#### **How to Fix 403 Forbidden Error**

The **403 Forbidden** error occurs when the server denies access to a requested resource. This can be due to incorrect file permissions, misconfigured `.htaccess` files, or security settings.

#### **1. Check File and Folder Permissions**

Incorrect permissions may restrict access to files and directories. The correct settings should be:

* **Folders:** `755`
* **Files:** `644`

To fix permissions via FTP:

1. Connect to your site via FTP.
2. Right-click on the root folder and choose **File Permissions**.
3. Set folder permissions to `755` and file permissions to `644`.
4. Apply changes and refresh your website.

#### **2. Review the .htaccess File**

A misconfigured `.htaccess` file can cause a **403 Forbidden** error.

1. Locate the `.htaccess` file in your website’s root directory.
2. Rename it to `.htaccess_backup`.
3. Try reloading the site. If the error is resolved, generate a new `.htaccess` file by going to **WordPress Dashboard > Settings > Permalinks** and clicking **Save Changes**.

#### **3. Disable Security Plugins**

Security plugins can sometimes block legitimate access. To check:

1. Access the **wp-content/plugins/** directory via FTP.
2. Rename the security plugin folder (e.g., `wordfence` to `wordfence_backup`).
3. Refresh the site to check if the error is resolved.

#### **4. Check IP Restrictions**

Some websites block access based on IP restrictions in the `.htaccess` file. Look for lines like:

```
Deny from all
Allow from 123.45.67.89
```

If your IP is not allowed, edit or remove these lines.

***

### **How to Fix 404 Not Found Error**

The **404 Not Found** error occurs when the requested page or resource cannot be found on the server. This usually happens due to broken links, missing files, or incorrect URL structures.

#### **1. Refresh and Check the URL**

* Ensure the URL is correctly spelled and formatted.
* Try clearing your browser cache and reloading the page.

#### **2. Reset Permalinks (WordPress Users)**

1. Log in to WordPress.
2. Go to **Settings > Permalinks**.
3. Click **Save Changes** to regenerate the `.htaccess` file.

#### **3. Restore Missing Files**

If a page is missing, restore it from a backup or re-upload the necessary files via FTP.

#### **4. Redirect Broken URLs**

Use a redirection plugin to point missing pages to a working URL. In `.htaccess`, add:

```
Redirect 301 /old-page.html https://yourwebsite.com/new-page.html
```

#### **5. Check for Plugin or Theme Conflicts**

Disable plugins one by one to see if a plugin is causing 404 errors. If using a custom theme, switch to a default theme (like Twenty Twenty-Three) and check if the issue persists.

***

### **How to Fix 502 Bad Gateway Error**

A **502 Bad Gateway** error occurs when the server acting as a gateway or proxy receives an invalid response from the upstream server. This is often due to server overload, network issues, or misconfigured server settings.

#### **1. Refresh the Page and Clear Cache**

* Press **Ctrl + F5** (Windows) or **Cmd + Shift + R** (Mac) to force reload the page.
* Clear your browser cache and cookies.

#### **2. Check Server Status**

* If using shared hosting, check if your hosting provider is experiencing downtime.
* Use online tools like **DownDetector** to check server status.

#### **3. Restart PHP and Web Server**

If you have access to your server:

* Restart Apache:

  ```bash
  sudo service apache2 restart
  ```
* Restart Nginx:

  ```bash
  sudo service nginx restart
  ```
* Restart PHP:

  ```bash
  sudo service php-fpm restart
  ```

#### **4. Disable CDN and Firewall Temporarily**

If using a CDN (like Cloudflare), try disabling it temporarily:

1. Log in to your CDN provider.
2. Pause or bypass the CDN service.
3. Refresh your site and check if the error is resolved.

#### **5. Check for High Resource Usage**

A sudden spike in traffic can overload your server. Check for excessive CPU or memory usage in your hosting control panel.

#### **6. Update or Reconfigure Server Settings**

If you have server access, try increasing server buffers by editing the **nginx.conf** file:

```
proxy_buffers 8 16k;
proxy_buffer_size 32k;
```

Restart Nginx after saving the changes.

***

### **Conclusion**

The **403 Forbidden**, **404 Not Found**, and **502 Bad Gateway** errors each have different causes and solutions. By following the troubleshooting steps outlined in this guide, you can quickly identify and fix these issues, ensuring a smooth user experience on your website. If the problem persists, reach out to your hosting provider for further assistance.
