How to Fix 403 Forbidden Error in WordPress?

As a WordPress plugin developer, you may have ever encountered a 403 Forbidden message on your WordPress site? It's annoying, I know. Don't worry, it's a common mistake, and you can fix it! Here's how to Fix 403 Forbidden Error quickly and easily!
What Is A 403 Forbidden Error?
A 403 forbidden error means you are not allowed to view a certain file/page on your website. You will see a 403 error message when viewing the front end of your site or when you are in your WordPress admin area. You will also see messages that say things like Access Denied.
Next, let's explore what can cause a 403 Forbidden Error.
1. Check File Permissions
If your file or folder permissions are set incorrectly, a file or folder can block access.
To fix this, simply:
- Log in to your site via FTP or your cPanel account.
- Press the button on "File and click on the folders."
- All WordPress Folders should have :
755
permissions - All WordPress files must have :
644
permissions
If you have access to SSH or shell commands access on your hosting provider, here is how you can set these using terminal:
find /path/to/your/wordpress-root/ -type d -exec chmod 755 {} \;
find /path/to/your/wordpress-root/ -type f -exec chmod 644 {} \;
2. Set Correct Ownership for files & folders
It is very important to set correct ownership rights to WordPress files & folders owned by the web server (Apache) user. For example:
chown -R www-data:www-data /path/to/your/wordpress-root/
3. Disable All Plugins
A security plugin could be blocking your access improperly.
To do that:
- Click on Plugins > Installed Plugins.
- Disable all plugins.
- Check if the error is resolved.
- This allows you to see which plugin is causing the problem.
4. Restore the .htaccess File
To restore .htaccess file, try this:
- Open your FTP program and find .htaccess in your site’s root folder.
- Rename it to .htaccess_old.
- Then, go back to your WordPress dashboard.
- Click on Settings > Permalinks and click “Save Changes.”
- This will create an error-free .htaccess file.
5. Check With Your Hosting Provider
Sometimes, the error is due to a firewall on your host's server that is blocking your access or a directed server configuration.
If the previous fixes did not resolve the issue, talk to your hosting provider.
They can examine the server rules and see if they can adjust the settings to allow you to go back.
6. Disable Hotlink Protection
- Some hosting providers perform hotlink protection. This feature can block access to your files when executed incorrectly.
- Log in to your hosting account, find the hotlink protection settings, and disable them. Refresh your website.
There’s also a chance you’re facing 404 Errors on WordPress Posts Alongside it, we have a solution for that as well.
Conclusion
The 403 Forbidden error in WordPress can be frustrating, but as you've seen, it's usually simple to fix. Start with file permissions, then check your plugins and your .htaccess file. If these solutions do not help, you can reach out to your hosting service.
After following these steps, you should be able to get your site back up and running in no time.