How to fix a 403 Forbidden error on cPanel?

Procédure

An HTTP 403 error is a web server error message that indicates that access to the requested page or resource is strictly forbidden for security reasons or due to access restrictions defined by the website. This error occurs when the server understands the request sent by the client, but refuses to authorize it for various reasons.

What Is a 403 Error?

An HTTP 403 error, also known as a 403 Forbidden error, is an HTTP status code that signals that a page or resource you are trying to access is unavailable for the moment, but the connection has been established. Unlike the 401 error, which is used for authentication failures, a 403 error is returned when the user is properly authenticated, but the user does not have the rights needed to access the resource.

Common reasons why a 403 error may be triggered include:

  • Access restrictions put in place by the owner of the site or resource, which may be based on IP addresses, geographic locations, or other criteria.
  • Attempts to access a directory rather than a specific page, when the web server is configured to refuse directory indexing or browsing.
  • Permission issues on the web server's files and directories, where the necessary files are not readable by the server.
  • The use of a misconfigured .htaccess file that restricts access to certain parts of the website.

Understanding the causes and potential solutions to a 403 error is important for web developers, system administrators, and end users seeking to resolve these issues and improve access to important web resources.

403 Error Displayed by LWS Protect

If the error page includes the mention “Powered by LWS Protect”, often with a detailed code (403.1, 403.2…) and, at the bottom of the page, the request identifier and IP address, the block comes from LWS Protect, the firewall of your cPanel hosting, and not from the Apache server. To find the rule causing the issue and know how to act, follow the help article 403 or 429 error from LWS Protect on cPanel: find the rule causing the issue and fix it.

How Do You Fix the 403 Forbidden Error Raised by the Apache Server?

How Do You Know if a 403 Error Is Generated by Apache?

If a 403 error is generated by Apache, you should see an error page matching the image below:

Apache server 403 “Forbidden” error page: “You don't have permission to access this resource”

How Do You Solve a 403 Error Generated by Apache?

Clear your browser cache

The first action to take is to clear your browser cache.

The cache is a useful tool that makes websites load faster. However, it can sometimes happen that the cached version of a page does not match its real version and that the 403 error is actually cached in your browser.

File restoration problem

If you recently restored files from a backup and have since been encountering 403 errors, it is possible that the file restoration partially failed.

The solution in this case is to start a new restoration and, after it is completed, check that the 403 error has permanently disappeared.

Check your file permissions

Each folder and file on your server has its own specific permissions that determine the actions allowed:

  • Read: allows you to view the data in the file or display the contents of a folder.
  • Write: allows modification of the file or the addition/removal of files in a folder.
  • Execute: allows the file to be run as a script or allows access to a folder and the execution of functions and commands.

These permissions are represented by a three-digit number, each digit indicating the permission level for the three categories mentioned above.

Normally, these permissions are only relevant for your site. However, problems with file permissions can lead to the 403 Forbidden error.

To check and modify your site's file permissions, you can use the file manager of your hosting account.

Once in the file manager, you can view the permissions of a file or folder (2) and modify them (1).

cPanel file manager: “Permissions” button (1) and “Permissions” column for the index.php file, at 0644 (2)

According to the WordPress Codex, the ideal file permissions for WordPress are:

  • Files: 644 or 640
  • Folders: 755 or 750

An exception is made for your wp-config.php file, which should have permissions of 440 or 400.

If file permission issues caused the 403 Forbidden error, your site should now work correctly.

Delete and restore the .htaccess file

A common cause of the 403 Forbidden error is a problem in your site's .htaccess file.

The .htaccess file is a configuration file used by the Apache web server. It allows you to configure redirects, restrict access to certain parts of your site, etc.

Because it is so powerful, even a small mistake can lead to a major problem, such as the 403 Forbidden error.

Rather than trying to troubleshoot the .htaccess file itself, an easier solution is to force WordPress to generate a new clean .htaccess file.

Here's how to do it:

  1. Log in to the file manager of your hosting account
  2. Find the .htaccess file in your root folder (1).
  3. Download (2) a copy of the file to your computer (it is always a good idea to have a backup copy just in case).
  4. Delete (3) the .htaccess file from your server after making a safe backup copy on your local computer.

cPanel file manager: .htaccess file selected in public_html (1), “Download” (2) and “Delete” (3) buttons

Now, you should be able to access your WordPress site if your .htaccess file was the problem.

To force WordPress to generate a new clean .htaccess file:

  1. Go to Settings (1) → Permalinks (2) in your WordPress dashboard.
  2. Click Save (3) changes at the bottom of the page (you do not need to make any changes — just click the button).

WordPress dashboard: Settings menu (1), Permalinks (2) and “Save Changes” button (3)

And that's it — WordPress will now generate a new .htaccess file for you.

Deactivate and then reactivate your plugins

If neither your site's file permissions nor the .htaccess file seem to be the issue, the next place to check is your WordPress plugins. There may be a bug in a plugin or a compatibility issue between different plugins.

To find the plugin responsible, we invite you to follow this documentation.

Temporarily disable the CDN

If you are getting 403 forbidden errors on your resources (images, JavaScript, CSS), it could be a problem with your content delivery network (CDN).

If you are using a CDN service such as Cloudflare, we recommend that you temporarily reconfigure the default LWS DNS to check whether the issue comes from the CDN.

Check whether Hotlink Protection is misconfigured

Hotlinking occurs when someone embeds an image on their site, but the link to that image still points to someone else's site. To prevent this, some people set up what is called “hotlink protection” with their host or CDN provider.

When hotlink protection is enabled, it usually generates a 403 Forbidden error. That is perfectly normal. However, if you are getting a 403 Forbidden error on something that should not be blocked, make sure hotlink protection is configured correctly.

Disconnect from your VPN

Here is another simple tip that could solve this problem if you are using a VPN.

Some sites may block access to users using a VPN, which could explain why you are encountering the 403 Forbidden error.

To check whether this is the case, disconnect from the VPN and try accessing the site another way. You can also try switching to another server offered by your VPN service.

Contact customer support

If none of the above solutions have worked for you, we recommend that you contact our technical support to benefit from a personalized analysis of your issue.

Conclusion

You now know how to:

  • Identify a 403 error and its possible causes.
  • Recognize a LWS Protect 403 error and find the help explaining how to fix it.
  • Carry out a repair of the 403 error caused by the Apache server, including clearing your browser cache, checking file permissions, and restoring the .htaccess file.
  • Deactivate and reactivate your WordPress plugins to eliminate compatibility issues.
  • Reconfigure DNS or temporarily disable the CDN in case of issues related to these services.
  • Ensure proper hotlink protection configuration to avoid unnecessary 403 errors.
  • Disconnect your VPN to test whether it resolves the 403 error.
  • Contact customer support if difficulties persist.

Resolving the 403 error can be complex, but with these tips and a little patience, you should be able to regain full access to your website. 😌🔧

Thank you for taking the time to read this article. If you have any questions or would like to share your experience with the community, feel free to leave a comment below. Your feedback is valuable and could help other users facing the same situation! 🙌💬

help.lws.net/a/1855
Was this article helpful?

Yes

No

Read 22 138 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

Need more help?

A question about this article?

Léo, our assistant, answers you straight away based on our articles.

A problem with your account?

Our technical support team handles your request by ticket, from your customer area.

Open a ticket