Undoubtedly, WordPress is the most preferred CMS platform in the world to run almost all types of websites. However, just as with any other platform, you may encounter some errors with WP occasionally.
The error ‘403 Forbidden’ is a common error in WordPress that may make beginners panic sometimes.
Indeed, ‘403 Forbidden’ is an HTTP status code that arrives when we don’t get permission to access or view a certain page on our site, perhaps because of some inaccurate configuration of our web server.
This error should look like this:
Have you recently found this error on your WordPress? Don’t panic, this article is going to educate beginners on how they can resolve WordPress 403 forbidden error on their WordPress without seeking professional help.
So get ready for it. But before that let’s see what are some major reasons causing this error.
When Can You Encounter 403 Forbidden Error in WordPress?
- You may encounter this error while creating a new post or editing the old one.
- Most of the time, it occurs after installing WordPress.
- Some people experience 403 forbidden error when they migrate their WordPress site from live server to local server.
- It occurs when you are unable to access any page of your WordPress website.
How to Fix Error 403 Forbidden
We are going to describe some common ways to fix this error. However, if you need a comprehensive information, 000webhost has presented a complete guide on how to fix error 403 in WordPress, you may refer that as well.
First: Take Backup
Before you jump into the solution section, first take backup of your entire WP site that you can do by login to your server through SSH.
Next, you need to go to your WordPress root directory. We recommend you to take a full archive backup of your entire WP site. It can be done by executing the following command:
Apart from this, you will also have to take a backup of your database as it stores all the information of your site including pages, posts, plugin configurations, users accounts, and comments as well. Use the following command to take a full backup of your database.
You have successfully taken the backup of WP site. Let’s move on to fix the 403 Forbidden error in WP.
Fixing ‘403 Forbidden’ Caused by Plugins
There is a chance that a faulty plugin is responsible for ‘403 forbidden’. One of the easiest ways to recognize if the issue is caused by a faulty plugin or not is to first disable all the plugins installed on your site temporarily.
See if the error is resolved after you disable all the plugins. If the error gets resolved it means it is definitely a plugin causing this error.
Now you can start turning the plugins back on. Turn on all plugins one-by-one and keep checking for when the error arrives again. It will help you identify the exact plugin causing this error. See, if this plugin needs upgrade or a fresh install.
Fixing ‘403 Forbidden’ Caused by File Permissions
Incorrect file permissions or wrong possession of your WP files and directories can be another big reason for ‘403 Forbidden’ error. You can use the following command to replace or change the ownership of WordPress directory.
See the following screenshot for the command.
- Replace first ‘www-data’ with the true web server users.
- Next, replace “/var/www/html/wordpress/”by the true path of the WP installation.
Go through the permission values and check different files and directories carefully. Make sure all directories have permissions set to 755 or 744 whereas for files permission values should be set to 644 or 640.
If you find any file or directory having wrong permission, change it manually. For instance, if you need to change the permission of the wp-content directory to 755, you will use the following command:
Note: Be careful while dealing with file permission on your server as your small negligence may easily break something. If you are not sure how to do this, it is better to contact your hosting provider. A good hosting provider should definitely help you in this matter.
Fixing ‘403 Forbidden’ Caused by Corrupt .htaccess File
There is a possibility that your .htaccess file has been corrupted. Sometimes, it may also cause a ‘403 Forbidden error’. Don’t worry fixing a corrupted .htaccess file does not take more than a couple of minutes through a trustful FTP manager.
The .htaccess file is found in your WP root directory. Apart from using FileZilla, you may use the following command to navigate to this directory.
Once you have found the .htaccess file next, you need to temporarily save it under a different name so that you can get the idea if .htaccess file is responsible for the error.
Simply use the following command to rename this file.
Once you have renamed the file, try loading your website to find if the error is resolved. If the problem still persists, it means the problem is not with the .htaccess file.
Now safely change it back to the actual name using the following command.
And in case if removing the .htaccess file settles the error, it simply means the .htaccess file is corrupted. Now you need to create a fresh .htaccess file holding the following information.
See the following screenshot
As you can see, the error ‘403 Forbidden’ is not a serious issue you should be scared of. If you have a reliable hosting partner with you, fixing the 403 Forbidden is not more than just a matter of few minutes.
Let’s run through a quick recap. To resolve this error all you need to do is follow the steps given below.
- Take the full backup of your site
- Check your plugins
- Check file permissions or user privileges
- Check your .htaccess file
Hopefully, you find this guide helpful. If you have any suggestions, feel free to share with us in the following comment section.