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:
Connect to your site via FTP.
Right-click on the root folder and choose File Permissions.
Set folder permissions to
755
and file permissions to644
.Apply changes and refresh your website.
2. Review the .htaccess File
A misconfigured .htaccess
file can cause a 403 Forbidden error.
Locate the
.htaccess
file in your website’s root directory.Rename it to
.htaccess_backup
.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:
Access the wp-content/plugins/ directory via FTP.
Rename the security plugin folder (e.g.,
wordfence
towordfence_backup
).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:
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)
Log in to WordPress.
Go to Settings > Permalinks.
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:
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:
Restart Nginx:
Restart PHP:
4. Disable CDN and Firewall Temporarily
If using a CDN (like Cloudflare), try disabling it temporarily:
Log in to your CDN provider.
Pause or bypass the CDN service.
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:
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.
Last updated
Was this helpful?