What is the WordPress 401 error code and how to fix it?
While updating your WordPress website, you may have faced issues in accessing the back end of your site or while you try to log in to your site. And all this is because of the WordPress 401 error.
What is the WordPress 401 error?
An HTTP error 401 occurs when the site or web page has problem in authenticating your browser credentials due to some reasons. It can be generated because of invalid credentials for a particular page or destination on your WordPress website. WordPress 401 error status is generally sent with a WWW-authenticate header and it contains details on how to authorize properly.
Like other error codes in the 400-range, the WordPress 401 error code indicates a problem on the client side. It is a sign of issue on your web browser’s side, rather than the website you are trying to visit. This 401 error can also lock you out of your site.
Depending on the server, the message indicating a 401 error code shows error code variations such as 401 unauthorized, authorization required, access denied or HTTP error 401 unauthorized.
What causes the WordPress 401 error code?
401 Error mainly pops up on the admin and login pages of the WordPress site. It could also appear on other pages of your website as well. First, let us discuss the typical causes of the 401 error code:
- Wrong URL
One of the causes of the WordPress 401 error code may be the wrong URL. So it is important to check and confirm the URL for the site you want to access and provide a correct URL.
- Improper authentication
To access a few pages in a website you often require to login in. And if you have not logged in or are trying to access the website or web pages with the wrong login credentials, you will get a 401 error, letting you know that you have made some mistake. So if you are getting a WordPress 401 error, make sure that you have logged in with accurate login credentials. You can gain access to the website by providing the correct username and password.
- DNS errors
Domain name system failures may also cause a WordPress 401 error.
- Plugin issues
Sometimes, you may notice a 401 error even without providing any password protection to your website. This may be due to a plugin on your WordPress site that is causing a WordPress 401 error code.
- Security measures
Another cause of getting a 401 error is security measures taken by hosting companies to protect your WordPress website against malicious activity. Some WordPress Security plugins or firewalls show this error when your WordPress login pages are accessed excessively.
- Erroneous login requirement
Many times, a website shows a login page. However, login is not required but still, it is shown. This may be because of some problem on the admin side and often show a 401 error.
Mostly, this problem is temporary and goes away on its own. However, if it persists for long, contact the admin to update them about the issue or clear your browser’s data. Re-loading the page again and again won’t do any good.
How to fix the WordPress 401 error?
As already discussed, a 401 error may appear due to multiple potential causes. So, often it becomes difficult to find out what is affecting your browser. You need to identify the exact cause of this error and then fix it.
Often, the 401 error can be fixed by simply refreshing the page. If it still doesn’t work, try the following fixes:
- Check the URL
The 401 error may be due to an incorrect URL or an outdated link or if there is some change in the login URL. So, make sure that you enter the correct URL.
- Flush your DNS records
Usually the computer accumulates all the data about the frequently accessed URLs and this helps to exercise future requests swiftly. Sometimes a WordPress 401 error occurs due to DNS errors. So, to fix it you need to flush your DNS records and delete all the interim data from your computer. So, whenever you again approach the problematic URL, it will be considered an entirely new request.
The DNS records flushing differ for Windows and Mac users. Windows users need to open the Command Prompt and enter “ipconfig/flushdns” in the CMD interface to delete all the existing DNS records. Similarly, Mac users need to enter sudo killall -HUP mDNSResponder.
- Clear your firewall data, browser caches and cookies
Internet browsers store data from various sites usually. So, whenever you access them, they don’t have to load sites again from zero, commonly known as a cache. Caches decrease the loading time of websites, resulting in an improved overall surfing experience. But, many times, you may store wrong login credentials without noticing or cache overlaps with the live version of the application, resulting in a 404 error code.
If the cache is the reason for the WordPress 401 error, you can fix it simply by clearing the cache. The cache can be cleared in just a matter of minutes in most of the latest browsers. For Google Chrome, you need to go to Settings > Advanced >Clear Browsing Data option. Select the Cached images and files and click ‘Clear data.’
Like cache, sometimes invalid and/or corrupted HTTP cookies also cause an authentication error. You just need to clear all the caches and cookies and try to open the page again.
If the 401 error problem still persists, it may be due to the firewall’s cache. Sometimes the firewall stops communicating with the server, resulting in authentication errors. The fixing of this depends on the tool you are using.
- Deactivate plugins and themes
Since WordPress plugins affect your site’s functioning, they may be a reason for the 401 error code on WordPress. It may be due to compatibility issues between the site’s plugins and themes. This can be fixed by simply deactivating the culprit.
To identify the plugin that is causing the 401 error, move to a WordPress default theme. Then deactivate all of the plugins at your site and start with reactivating them one-by-one. Keep checking if the error only appears after installing a new plugin. When you get the culprit, deactivate that plugin.
WordPress security plugins often intend to cause a 401 error. Some security plugins lock down the WordPress login page thinking that it is under attack. As a result, when you try to access the login page, it triggers the 401 error code.
Once you have identified the concern by deactivating the plugin, contact the plugin’s support and try to understand the cause. Disabling the WordPress themes also works likewise.
- Remove password protection for testing
Protecting your WordPress directories with passwords adds an extra level of security beyond the Login page. But this password protection does not cover a recovery process for log-in credentials. In case you forget them, you get locked out. To gain access to the account, you may try removing password from the account for a while.
Here is how to do it:
- Use FTP to gain access to the required directory.
- Locate the .htaccess file within the WordPress root directory and disable password protection for all your directories.
- Each relevant directory consists of a second file known as .htpasswd. Delete it for the folder you want to access.
Sometimes, the 401 error may be caused due to maintenance activities going on at the backend. It may cause temporary login issues. Few hosting companies sometimes block the IP of a few sites thinking that there is something spiteful, like entering the wrong password. So we recommend you wait for some time and log in after a while.
- Contact your hosting provider
Even after trying all the above-suggested solutions, if the 401 error still persists, it may be a server-related problem. So we recommend contacting your hosting provider.
A WordPress 401 error indicates a client-side issue while authenticating itself with your WordPress site’s server. We hope that the tips provided here will help you to fix the 401 error in the WordPress site. Before contacting your hosting provider tries to resolve the error by checking the URL and clearing all browser cache and cookies data, removing DNS records, deactivating plugins and server-level passwords you might have added.
24x7WPSupport team can help you in identifying the cause of the error with the help of our highly capable diagnostic tools. Contact us if your site shows 401 Error to visitors unnecessarily.