Websites require constant maintenance and updates to function optimally. Sometimes changing things, or even not changing things correctly, can result in errors on a website.
In this post, you will learn what a 403 Forbidden Error is and how to quickly fix it.
Requests you make to a server can return a variety of status codes. One such status code is 403. The 403 Forbidden error basically means that the server understands your request, but is denying users access to a certain resource on your website.
Providing more information about the reason for the requested ban is up to the servers.
There are many things that can cause a 403 error. However, the three most common reasons that can result in a 403 error are:
Incorrect file permissions are another reason that can cause a 403 error. Files and directories on computer systems have certain permissions assigned to them. This prevents people from reading, writing, or executing a file that they don't have access to. It's important to keep sensitive files protected, but files and directories that are part of WordPress need to have permissions assigned in such a way that they meet the basic minimum requirements.
In this section, we will learn how to fix the 403 Forbidden error, either by restoring our .htaccess file or by setting the proper file permissions.
It is possible to modify the .htaccess file of your WordPress installation in three different ways. Sometimes WordPress core modifies it, and other times some plugins make changes to this file. It is also possible that you have manually made changes to it.
In any case, the easiest way for beginners to get rid of a 403 error caused by a .htaccess file is to remove the old version and force WordPress to generate a new one.
Make sure to create a new backup of the old .htaccess file before you delete it. Save it locally on your computer or somewhere else. If generating a new .htaccess file doesn't resolve the error, you can simply reload the new backup and continue to the next step.
You should see a .htaccess file once you've logged into the root directory of your website in your FTP client. Right-click on it to download a local copy first, then delete the file.
Now try to visit your website. If it opens successfully, this means that some rule within the .htaccess file was causing the error. In this case, you can generate a new .htaccess file by simply going to the WordPress admin panel, then navigation to Settings > Permalinks and click Save Changes
Specifying the correct value for file permissions allow you to keep your website secure while providing access to the users who need it to keep things running smoothly. The general rule of thumb to keep in mind is to start with restrictive permissions and then increase them until things start working. Fortunately, we don't need to do all of these tests to determine the correct permissions for our WordPress website.
Within our WordPress installation, you can set permissions for all directories in 755and permissions for all files in 644. This should fix any 403 errors that arise due to incorrect file permissions. The meaning of permission numbers, such as the 755, is explained in more detail in the official WordPress documentation.
There are free FTP clients, like FileZilla or WinSCP, that you can use to set these permissions on different files and directories recursively.
You can check the current permissions of a file or directory by right-clicking on its name and then selecting File Permissions from the context menu.
This should bring up a dialog that shows you the currently applied permissions and asks if you want to recursively apply them to different files and subdirectories.
Creating a new .htaccess file or setting the file permissions correctly fixes the 403 Forbidden error problem for most users. One more thing you can try, in the unlikely event that the error is still appearing, is to disable all plugins. A poorly coded plugin or incompatibility between different plugins, among other things, can also result in 403 errors.
Once all the plugins have been disabled, check if the website is still showing a 403 error. If the website is now loading, it means that one of the plugins is causing the 403 Forbidden error. Now start activating the plugins one by one to see when the error occurs again. This will tell you which plugin is causing problems, and you can contact its developer to fix the error or install an alternative plugin instead.
In this post, we have covered the three most common issues that can lead to a 403 Forbidden error in WordPress. Hopefully one of them will fix your problem. You should consider contacting your web host if the error persists. Your provider might suggest other things you can do.