Are you facing a 401 error on your WordPress website?
This guide is for you.
WordPress 401 error as known as the Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.
In this context, we shall look into methods to fix WordPress 401 error.
What triggers WordPress 401 Error to occur?
There are different reasons for this error to occur. It includes improper authentication while communicating with the WordPress hosting server.
For instance, if the website admin folder has password protection then not entering a password would throw this error message.
But, sometimes this error can occur even without adding any special password protection to the website.
Security measures are taken by hosting companies to protect your WordPress website also can be a cause for this error.
These security measures start showing this error when the WordPress login pages are accessed frequently.
How to resolve WordPress 401 Error ?
Follow the steps given below to resolve this error message.
1. Remove Password Protection Temporarily
Sometimes, customers tend to forget the admin directory password.
So it would be a great idea to disable this password protection from the login page.
These steps can work for a few of the hosting companies but not all.
i. First, we access the WordPress hosting cPanel and locate the Directory Privacy or Password Protected Directories icon.
ii. Next, we browse to the wp-admin directory and click on it.
iii. After that, the control panel will now display its password protection settings. We simply uncheck the box next to 'Password protect this directory' option and click on the Save button.
iv. Then, we click on the Go Back button and scroll down to the bottom of the page.
From here we delete the username we used to login to the password-protected directory.
v. Finally, this successfully disables password protection for the WordPress admin directory.
2. Clear Firewall Cache to fix 401 error
Some customers do use some Cloud-based WordPress firewalls like Sucuri or Cloudflare. So, when the firewall fails to communicate with the website, this error can occur.
So, we suggest our customers purge their cache in their respective firewall providers.
3. Deactivate All WordPress Plugins
Sometimes, the plugins would be a culprit.
So by deactivating the plugin we can check if any plugin is causing the issue.
i. In order to deactivate the plugin, we log into the WordPress dashboard and go to the Plugin page and deactivate the plugins.
ii. However, if we are not able to log into the dashboard then we can disable it via FTP.
iii. For that, we first connect to the FTP and access the website folder and go to /wp-content/ folder and rename the plugins folder to plugins.deactivated.
Renaming the plugins folder thus way will deactivate all WordPress plugins.
iv. Now we can visit the WordPress website’s admin area and try to log in. If everything works fine, then this means that one of the plugins was causing the issue.
v. We then switch back to FTP client and once again rename the plugin’s folder to just plugins.
vi. Next, we return to the WordPress admin area and go to the plugins page. Then we activate each plugin one at a time until we start seeing the 401 error again.
This way we find the culprit plugin.
4. Switch to a Default WordPress Theme
A function within the WordPress theme may also cause some issues.
So in order to find it out, we can temporarily switch to a default theme.
For that, we access the WordPress dashboard >> Appearance >> Themes page.
Now if there is a default WordPress theme installed, then we can go ahead and activate it.
If there is no default theme then we install it and activate it.
After that, we try accessing the website and check if the error resolves.
This way we can check if the theme is causing any issue.