How to Fix the 401 Error in WordPress
Is there a 401 error on your WordPress site?
The 401 error is also known as 401 unauthorized error or Error 401. Sometimes, these errors are shown by a message ‘Access is denied due to invalid credentials’ or ‘Authorization required.’
We will share different solutions to fix the 401 error in WordPress easily.
What Causes the 401 Error in WordPress?
In WordPress, the 401 error occurs when you have password-protected your WordPress admin folder and not entered a correct password. It then displays a 401 error page on admin pages and WordPress login.
In addition, you may also notice this error if you have installed any WordPress security plugins on your site. It can lock your admin area during a forced login.
The other cause for this error may be the security measures taken by your hosting companies to protect your WordPress site. The security measures display this error when excessive login attempts are made to your WordPress login page.
Generally, the 401 error arises on WordPress login and admin pages. However, it may appear on all pages of your WordPress website.
You have to find out the actual cause of the error and then fix it accordingly.
Now, moving on to the solutions to easily fix the 401 error in WordPress.
Temporarily Remove Password Protection
If you have protected your WordPress admin directory by a password, then you could try this solution.
If you do not remember your admin directory password or your server configuration is adjusted, don’t panic. Just follow the method below to remove the Password.
First, Visit your WordPress hosting control panel and search for the Directory Privacy or Password Protected Directories icon. Most of the hosting panels include this option.
Once you get it, click it, and you will notice all the files and folders on your hosting account. Go to your wp-admin directory and select it.
Now the control panel will show its password protection settings. Then, uncheck the box besides the ‘Password protect this directory’ option and click on the Save tab.
After that, click on the Go Back tab and scroll to the bottom of the page. Now, delete the username you used to access your password-protected directory.
After this, You have disabled password protection for your WordPress admin directory. Now, try to access your WordPress site.
If your site is working properly, then you can enable password protection for your WordPress admin area by using a new username and Password.
Reset WordPress Password
WordPress hosting companies may sometimes restrict access to wp-admin and login pages if someone is trying to enter a password again and again.
It could block your access temporarily, and you can try it after some time.
However, if you forget your password, you can recover the forgotten WordPress password from the lost password link instead of guessing your password.
After clicking the link, WordPress sends an email with a link to change your Password.
However, if WordPress fails to send emails or you don’t get the email, then you can also reset the WordPress password using phpMyAdmin.
If this doesn’t fix your issue, try using the next step.
Deactivate All WordPress Plugins
A faulty or poorly configured WordPress plugin can also generate a 401 error. To check this out, you have to deactivate all WordPress plugins temporarily.
You can deactivate WordPress plugins from your admin area by visiting the plugins page.
But if you cannot access your WordPress admin area, then you can deactivate all WordPress plugins using the FTP client.
First, connect with your WordPress site using an FTP client. After that, visit /wp-content/ folder and rename the plugins folder to plugins.deactivated.
When you rename the plugins folder, it will deactivate all plugins on your site.
Now visit your website admin area and try to log in. If you are able to access it and everything is working properly, this suggests that the error was because of a faulty plugin on your site.
Now return to the FTP client and rename the plugin’s folder to plugins again.
Next, go to your admin area again and head over to the plugins page.
Now activate the plugins one by one until you notice the 401 error again.
This way, you can detect the faulty plugin. Once you get the plugin causing the error, you can deactivate it and find an alternative plugin.
Switch to a Default WordPress Theme
If the plugin solution does not resolve the issue, it may be a function inside your WordPress theme that is causing the 401 error on your site. To check this out, you have to switch to a default WordPress theme temporarily.
You can use any default theme such as Twenty Sixteen, Twenty Seventeen, Twenty Nineteen, and more.
First, visit the Appearance » Themes page. If you already have a default WordPress theme installed on your site, then go ahead and activate it.
If you don’t, then you have to install and activate it.
After switching to the default theme, visit your website and see if the error disappears and everything is working properly. This suggests that the theme you were using was causing the 401 error.
Now, you can discuss the issue with the theme developer. They will be able to fix it.
Clear Firewall Cache to fix 401 Error in WordPress
If you use a cloud-based firewall service in WordPress such as Sucuri or Cloudflare, then a 401 error may arise when the firewall fails to connect with your website. You can resolve the issue by following ways.
- Clear Cache in Sucuri Firewall
If you use Sucuri, log in to your Sucuri dashboard and go to the ‘Performance’ page. Now, click the ‘Clear Cache’ option and then select the ‘Clear cache’ tab.
- Clear Cache in Cloudflare
If you use Cloudflare, first log in to the Cloudflare dashboard and visit the ‘Caching’ section. Now click on the ‘Purge everything’ tab to clear all cache.
Once you have cleared your firewall cache, next, you have to clear your browser cache or WordPress cache as well. For more details, you can see our tutorial on how to clear cache in WordPress.
Contact WordPress Hosting Provider
If the above solutions could not fix the 401 error on your site, then you can try contacting your WordPress hosting provider.
Many hosting companies automatically notice doubtful activity on a website and block access to prevent attacks.
This security protection sometimes only affects the WordPress admin area, and your login page may become unavailable for some time.
However, if your site does not return to a normal state or you see a 401 error on all your site pages, you have to immediately get in touch with your WordPress hosting provider.
They will check the access and error logs to fix the issue for you.
To Conclude: There may be many reasons why your WordPress is displaying the 401 error. It may be due to a faulty plugin or theme, or you entered the incorrect login details. You can try fixing the 401 error following the steps stated above.
We hope one of these solutions helped you fix the 401 error in WordPress.
If you are experiencing any other error on your site, you can fix it by following the steps told in our other article on what to do when you are logged out of the WordPress admin area.