If you get a 401 Unauthorized error when attempting to visit a website, you should do something about it. Whether you’re the site’s owner or a visitor, the frustration of getting an HTTP error 401 error can be unbearable. The issue can be only temporary in many cases, luckily. Plus, before you get annoyed or even enraged, you should know that there are several solutions to the issue. Since over 40% of indexed websites use WordPress, this problem usually crops up with this Content Management System (CMS), making our job easier.
But before you learn what the fix could be, we’ll let you know everything about the Unauthorized 401 error.
What is 401 Unauthorized Error?
When you see a “401 Authorization required” error, it means that the page you were trying to reach is password-protected, and you haven’t entered the right credentials. It’s one of the most common HTTP status codes, along with 404 Not Found and 500 Internal Server Error.
The 401 HTTP code may also occur if there are some issues with the website’s .htaccess file or web server permissions. With that said, here is a collection of possible solutions to fix the 401 Unauthorized error.
Possible reasons behind the 401 Unauthorized Error
The 401 error happens when your web browser has trouble authenticating your login credentials with the server. Although this error is mostly on the client side, sometimes server-side issues can also result in a 401 unauthorized error.
Generally speaking, a client-side error is much easier to rectify than a server-side issue, but for any troubleshooting to happen, one must first understand the root cause behind the error, and this is what we are going to try by explaining a few common reasons behind the infamous 401 error.
1. Incorrect URL
If you type in the wrong URL, then obviously it will result in an error as the DNS won’t be able to route your traffic to the right website. It is one of the most common mistakes made when it comes to 401(k) unauthorized access and one that is the easiest to rectify.
2. Outdated cookies or corrupted cache data
Then we have outdated cookies or corrupted cache data that can interfere with the website lookup process as the browser will first access the cookie to load the site faster. However, if there is any inconsistency between the cached data and the current website, it will result in an error.
3. IP address blocked
If your IP address has been blacklisted by a website or the ISP for a relative service, then it automatically becomes much harder for you to access a site. This block might be a result of a government policy or due to the website’s choice. But accessing a website with a blacklisted IP address will result in a 401 error.
4. Server configuration settings
Yes, the settings of the server and website configuration can also play a part when it comes to authentication. Now, it is exactly the type of error that falls under server-side issues and is impossible for a client to troubleshoot, as any changes needed can only be made on the server end.
5. Incorrect username and password
It is a simple issue, as many of us have experienced this time and time again when we try to log in or access a particular website and enter an incorrect username or password. Doing so will prevent our access, as the website will not be able to authenticate it.
Fixes for the 401 Unauthorized Error
1. Check Your Site Login Credentials
This is the first thing you should do when seeing a code 401 HTTP error. Simply check if you’ve entered the right login details. If you’re unsure, reset your password. If the issue persists, consider reaching out to Customer Support, if it exists.
2. Clear Browser Cache and Cookies
If you still can’t fix the response code 401 error, try clearing your browser cookies and cache. Over time, these files can get corrupted and cause problems while loading a website. To clear your browser cache, follow the steps below:
1. Delete Chrome Cache
Clearing cache in Chrome works this way:
- Do one of the following:
- Press Ctrl + Shift + Delete shortcut keys together to open the “Clear Browsing Data” window.
- Click on the three vertical dots in the top-right corner of Chrome and select More tools > Clear browsing data from the dropdown menu.
- In the “Clear Browsing Data” window that appears next, check all the boxes and click on the Clear data button.
2. Remove Cache from Firefox
The procedure is similar:
- You have two options:
- Press the Ctrl + Shift + Delete keys at once.
- Click on the three horizontal lines in the top-right corner of Firefox and select History > Clear Recent History from the dropdown menu.
- In the “Clear All History” window, set the Time range to “Clear to Everything.” Now, check all the boxes and click on the Clear Now button.
3. Clearing Edge Cache
Proceed to click the three horizontal dots in the top-right corner of Microsoft Edge and:
- Select Settings, then choose what to clear from the dropdown menu.
- Head to “Clear browsing data pop-up,” check all the boxes, and click on the Clear button.
If you are using another browser, search for how to clear cache and cookies on the Internet. Many are Chromium-based, meaning instructions will be nearly identical to the Chrome ones.
3. Fix 401 Unauthorized Error by Disabling Security Plugins or Firewalls
Now we are getting into the site owner guide. If you have any security plugins or firewalls installed on your WordPress site, try disabling them and see if the 401 authentication shows up. Once you find the culprit, contact the plugin author for further assistance.
4. Check Your .htaccess File
The next step is to check your WordPress site’s .htaccess file for any corrupt code. Connect to your WordPress site using an FTP client and:
- Navigate to the ~/wp-content/ directory.
- Now, right-click on the .htaccess file and select View/Edit.
- Once the file opens in a text editor, look for any suspicious code or text strings and delete them.
- Once you’re done, save the file and upload it to the server.
5. Change File Permissions to Fix 401 Unauthorized Error
If the problem persists, try changing your WordPress site’s file permissions. By default, the following are the recommended file permissions:
- For directories: 755
- For files: 644
You can change file permissions using an FTP client or cPanel. If you’re unsure how to do it, contact your web hosting provider for assistance.
6. Re-upload Some Core WordPress Files
If none of the above methods work, uploading your WordPress site’s core files again might do the trick. Connect to your WordPress site using an FTP client and navigate to the /wp-admin/ directory. Now, delete the following files:
- admin-ajax.php
- favicon.ico
- index.php
- license.txt
- readme.html
- robots.txt
- user-new.php
Once you’ve deleted these files, go back to the WordPress.org website and re-download a fresh copy of WordPress. Connect to your WordPress site using an FTP client and upload these newly downloaded files to your WordPress site’s /wp-admin/ directory.
7. Fix 401 Unauthorized Error by Reinstalling WordPress
If the concern persists, the last resort is to reinstall WordPress. This will delete all your existing content and settings, so make sure you take a backup of your site before proceeding. Once you’re ready, connect to your WordPress site using an FTP client and delete the following directories:
- /wp-admin/
- /wp-includes/
Now, go back to the WordPress.org website and download a fresh copy of WordPress. Once you have the ZIP file, extract it to your local computer. Connect to your WordPress site using an FTP client and upload these extracted files to your WordPress root directory.
8. Look for a malformed authentication request
If you are a web admin or developer, then you need to check the API documentation carefully. The user credentials have to be formatted in a particular manner before the server can authenticate them. Thus, by ensuring the right constructs and using the correct hashing and cryptography techniques, developers can prevent the error.
9. Need for the required permission or access control clearance
No matter if you are an admin or an end user, before even attempting to access any website or its resources, you have to ensure that you have the necessary permissions or access clearance. If you do not have sufficient credentials, then you should get them by contacting the owner of the resource.
10. Make changes to the Firewall or Network Security
At times, you must make the necessary changes to the firewall; otherwise, your attempt to access a particular website will be thwarted by your network security. If the ISP is the one preventing your access, then either talk to them about why you need access to a particular website or use workarounds like VPNs or proxies.
11. Flush the DNS
Finally, your DNS might also be the culprit behind the entire 401 debacle. Thus, by flushing the DNS, you might be able to access the website. Some DNS servers block particular IP addresses. By flushing the DNS, you can refresh the database, which can be helpful.