How to quickly fix the 401 unauthorized error (5 methods) (2024)

Trying to access a site and being met with an error page is always inconvenient, whether that site is yours or someone else’s. As with many HTTP response codes, part of what makes a 401 error so frustrating is the lack of information it offers for diagnosing and resolving the issue.

The 401 error can happen with any browser, so it’s a pretty common issue people face. In most cases, this problem is relatively simple and straightforward to fix.

This post explains what 401 error messages are and why they happen. It then walks you through five methods you can use to fix them.

Let’s get started!

What is the 401 error code?

The Internet Engineering Task Force (IETF) defines the error 401 Unauthorized as:

The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. The server generating a 401 response MUST send a WWW-Authenticate header field containing at least one challenge applicable to the target resource.

An introduction to the 401 error code

HTTP 400 status codes are encountered when there is a problem making a request. A 401 error, in particular, happens when your browser denies you access to the page you’re trying to visit.

As a result, instead of loading the web page, the browser will load an error message. 401 errors can happen within any browser so the message appearing may differ.

For example, in Chrome or Edge, you’ll likely see a paper icon along with a simple message telling you that the page in question isn’t working. It will include the phrase “HTTP Error 401” at the bottom, and instruct you to contact the site’s owner if the problem persists:

How to quickly fix the 401 unauthorized error (5 methods) (1)

At other times and in other browsers, you might get a slightly less friendly warning that’s just a blank page with a “401 Authorization Required” message:

How to quickly fix the 401 unauthorized error (5 methods) (2)

Other variations include:

  • “HTTP 401 Error – Unauthorized”
  • “401 Unauthorized”
  • “Access Denied”

These errors occur on websites that require a login in order to access them. In most cases, it means that something is either wrong with the credentials or with the browser’s ability to read them as valid.

This is similar to HTTP 403 Forbidden Error, in that access isn’t permitted to the user. However, unlike with the 403 error, the 401 error message indicates that the authentication process failed.

The code is sent via the WWW-Authenticate header, whichis responsible for identifying the authentication method used for granting access to a web page or resource.

Error CodeHTTP 401 Unauthorized Error
Error TypeCommonly a client-side error
Error Variations401 Authorization Required
401 Unauthorized
HTTP 401 Error – Unauthorized
Access Denied
Error CausesOutdated Browser Cache and Cookies
Plugin Incompatibility
Incorrect URL or Outdated Link

What causes a 401 error?

If you encounter an error code in the 400s, you know you’re dealing with a client-side (or browser-side) issue. While the problem may be happening within your browser, however, it doesn’t necessarily alwaysmean that’s the culprit, which we’ll explain in more detail later.

401 errors occur on restricted resources, such as password-protected pages of your WordPress site. So it’s safe to assume that the cause of the problem has something to do with the authentication credentials.

  1. Outdated browser cache and cookies — One of the most common reasons you might experience a 401 error is that your browser’s cache and cookies are out of date, preventing the authorization from successfully going through. If your browser isn’t using the valid authentication credentials (or any at all), the server will reject the request.
  2. Plugin incompatibility — At other times, this error is caused by plugin incompatibility or error. For example, a firewall or security plugin can mistake your login attempt as malicious activity, and return a 401 error to protect the page.
  3. Incorrect URL or outdated link — It’s also possible that the source of the problem can be attributed to a minor mistake. Common culprits in this category include an incorrectly-typed URL or an outdated link.

How to fix the 401 error

Now that we’ve gone through a bit of background on the 401 error, it’s time to discuss how you can resolve it.

Let’s take a look at five methods you can use:

1. Look for errors in the URL

Start off with the easiest potential fix: making sure you used the correct URL. This may sound simple, but 401 errors can sometimes appear if the URL wasn’t correctly entered in.

Another possibility is that the link you used to visit the page in question points to the wrong URL. For example, it might be outdated, or leading to a page that no longer exists (and no redirects are in place).

Therefore, it’s worth double-checking the URL you used. If you typed it in yourself, verify that you spelled everything correctly. If you clicked on a link, confirm that it’s pointing to the page you’re trying to access (or try to visit that page directly through the website).

2. Clear your browser’s cache

Your browser’s cache is designed to improve your online experience, by reducing page loading times. Unfortunately, sometimes it can also cause unwanted interruptions.

As mentioned earlier, one of the common causes of the 401 error is outdated or incorrect cache data or cookies. Therefore, if you don’t notice any issues with the page’s URL, the next step is to clear your browser’s cache.

This will clean out any invalid information that’s locally stored in your browser, which could be interrupting the authentication process. Similarly, your browser’s cookies might contain authentication data that simply needs to be refreshed.

If you’re a Google Chrome user, you can do this by clicking on the menu icon in the top-right corner of the browser, and then going to Settings. Under the Privacy and security section, click on Clear browsing data:

How to quickly fix the 401 unauthorized error (5 methods) (3)

A new window will open. Under the Basictab, make sure all three boxes are selected, and then select Clear data:

How to quickly fix the 401 unauthorized error (5 methods) (4)

This process will look a little different in other browsers. For example, in Mozilla Firefox, you would click on the library icon in the top-right corner of the browser, followed by History> Clear Recent History:

How to quickly fix the 401 unauthorized error (5 methods) (5)

In the panel that opens next, select Everythingin the drop-down menu at the top, make sure Cache is selected, and then click on the Clear Nowbutton:

How to quickly fix the 401 unauthorized error (5 methods) (6)

If you’re using a different browser, please refer to this guide for clearing the cache

3. Flush your DNS

Another method you can try to resolve the 401 error is flushing your Domain Name Server (DNS). While this is a rare issue, it canbe a possible cause, so it’s worth giving it a try if the first two solutions don’t work.

To do this in Windows, click on the Start button and type cmd into the search bar. Hit Enter, and the Command Prompt will open. Copy and paste the command ipconfig/flushdns, and then hit Enteragain:

How to quickly fix the 401 unauthorized error (5 methods) (7)

On a Mac, you can do this by going to Finder > Applications > Utilities > Terminal:

Input the command line sudo killall -HUP mDNSResponder and press Enter. Then, you can try refreshing the page you were trying to visit, to see if the 401 error has been resolved.

4. Deactivate your WordPress plugins

The problem causing your 401 error might not be due to your browser. If you’re having trouble accessing your WordPress site, it’s also possible that one or more plugins are to blame.

Some plugins, especially security-focused plugins, are configured to show a 401 error when they suspect suspicious login activity that might indicate an attack. Others might just be suffering from compatibility issues. Therefore, it’s a good idea to deactivate all of your WordPress plugins and see if that resolves the issue.

You can deactivate your plugins all at the same time in your dashboard, by going to Plugins > Installed Plugins. Check the box at the top to select all of them. Then under the Bulk Actionsdrop-down menu, select Deactivateand click on the Apply button:

After that, try reloading the page that returned the 401 error to see if this has resolved the issue. If it has, you can manually activate each plugin one at a time, in order to determine which one is causing the problem.

Then you can remove that plugin, replace it with a new one, or contact its developer for assistance.

5. Check the WWW-Authenticate header response

At this point, if the issue hasn’t been fixed, it may be caused by a server-side problem. This means our last fix will be a bit more involved.

As we saw earlier, the 401 response is sent through the WWW-Authenticate header, which appears as WWW-Authenticate: <type> realm=<realm>. It includes ‘challenges’, or strings of data that indicate what type of authentication is required in order for access to be granted.

In a nutshell, you want to check and see if the header response was sent, and more specifically, what authentication scheme was used. At the very least, this can help narrow down the cause of the problem, and bring you one step closer to a solution.

To do this, go to the web page that’s displaying the 401 error, and access the developer console in Chrome. You can right-click on the page and select Inspect, or use Ctrl+Shift+J.

Next, click on the Networktab and reload the page. This will generate a list of resources. Select the Status header to sort the table and locate the 401 status code:

How to quickly fix the 401 unauthorized error (5 methods) (10)

Select that entry, and then click on the Headerstab. Under Response Headers, locate the WWW-Authenticate header:

How to quickly fix the 401 unauthorized error (5 methods) (11)

The information that is present in the response header, particularly the authentication schemes, can give you more information about what’s happening and point you towards a solution. It can help you understand what type of authentication the server is expecting.

For example, in the above example, we can see that the authentication scheme is “Basic”. This means the authentication request should only require an ID and password. For more detailed information and instructions on how to use this information, we recommend referring to the HTTP Authentication Scheme Registry.

Summary

When your browser and server have trouble communicating or authenticating requests, you’re sometimes forced to deal with errors such as the 401 error. While this problem is irritating, the message is usually temporary and fixable.

How to quickly fix the 401 unauthorized error (5 methods) (2024)

FAQs

How to quickly fix the 401 unauthorized error (5 methods)? ›

To debug a 401 error in an API: - Check request authorization credentials. - Review API docs for requirements. - Verify token or credentials validity. - Inspect request details (headers, params).

How do I fix an Unauthorized 401 error? ›

In this guide, we've gone over the most common methods to solve the 401 error:
  1. Confirm the URL is correct. Double-check the URL in case it's misspelled or outdated.
  2. Clear cache. ...
  3. Check authentication credentials. ...
  4. Disable password protection. ...
  5. Troubleshoot the code.

How to debug 401 Unauthorized error? ›

To debug a 401 error in an API: - Check request authorization credentials. - Review API docs for requirements. - Verify token or credentials validity. - Inspect request details (headers, params).

What is the root cause of error 401? ›

401 errors occur when a web browser has trouble authenticating the visitor's login credentials with the website's server. Here are a few common causes why that might happen: Error or typo in the website's URL. Outdated cookies or browser cache.

What is the most common cause of 401 Unauthorized errors on a website? ›

This error can occur with any browser when a visitor fails to provide valid authentication credentials (e.g., incorrect URLs, outdated browser cache or cookies, plugin misconfiguration, etc.). As a result, a variation of 401 error messages may appear on the screen depending on the browser the visitor is using.

What is status code 401 unauthorized? ›

The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.

What is 401 unauthorized when communicating with? ›

Missing or Incorrect Authentication Credentials

As stated earlier, the most common cause of a 401 Unauthorized error is a client not providing valid authentication credentials, such as a username and password, in the request. This can happen if the client forgets to include the credentials or enters them incorrectly.

What is 401 Unauthorized access denied due to invalid? ›

The server's response of “401 Unauthorized access is denied due to invalid credentials” signifies that the requested resource requires authentication. However, the credentials provided by the client, such as username, password, API key, or token, are either missing or incorrect.

How do I trigger a 401 error? ›

You may see the “Error code 401” if you try to access an outdated or misspelled URL. It means that the URL is non-existent, and the server may return a server error “401 Unauthorized Access”. Maybe you saved the page address in your browser, but the page address has been changed, or it has been deleted.

How to fix the remote server returning an error 401 Unauthorized? ›

Make sure email parameters, SMTP server, username, password and any other relevant settings are accurate. The error message specifically mentions "401 Unauthorized," which is usually related to authentication issues. Double check the email account credentials used to send the email.

Why is 401 unauthorized instead of unauthenticated? ›

The HTTP status code 401, often denoted as UNAUTHORIZED , signifies that the client lacks proper authentication credentials or has provided invalid credentials. In simpler terms, the server has failed to identify the user.

What does 401 error return? ›

This response means that no valid session was found for the session token passed to the API. The user attempting the request is not logged into the REST API for one of the following reasons: The user has not yet logged in.

What is forbidden error 401? ›

The "401 Unauthorized" status code indicates that the request lacks valid authentication credentials. On the other hand, the "403 Forbidden" status code signifies that the server understands the request but refuses to fulfill it.

How to quickly fix the 401 unauthorized error? ›

4 Different Methods to Solve the 401 Error
  1. Clean Up Your Browser Cookies and Cache Data. You may already know that browser cookies and cache data improve user experience on several websites. ...
  2. Double-Check the Inserted URL. ...
  3. Flush the DNS Cache. ...
  4. Disable Several Modules, Themes, and Plug-ins.

How to clear a 401 error? ›

Clear your browser's cache

As mentioned earlier, one of the common causes of the 401 error is outdated or incorrect cache data or cookies. Therefore, if you don't notice any issues with the page's URL, the next step is to clear your browser's cache.

How to fix blocked due to unauthorized request 401? ›

Option 1: Allow Googlebot to crawl your pages

For the 401 pages you want to index, you need to change the server settings so that Googlebot can visit and crawl their URLs. This means that your server will have to treat Googlebot differently than users' browsers.

How to disable browser's default login prompt on 401 response? ›

There are two things you can try:
  1. If you can control the HTTP response, you can remove the WWW-authentication header from the response. Or explicitly set the www-authenticate header to an empty string to make it work. ...
  2. If you have access to the code for the web service that is returning the 401.
Aug 28, 2022

What is 401 attempted to perform an unauthorized operation? ›

Error: "status code 401 and description: Attempted to perform an unauthorized operation." This occurs when the collector can't access the Azure Event Hub API.

What is 401 unauthorized access denied due to invalid? ›

The server's response of “401 Unauthorized access is denied due to invalid credentials” signifies that the requested resource requires authentication. However, the credentials provided by the client, such as username, password, API key, or token, are either missing or incorrect.

What is the difference between 401 and 403 error? ›

The Basics of HTTP Status Codes

In the 4xx class, 401 and 403 are particularly noteworthy. The "401 Unauthorized" status code indicates that the request lacks valid authentication credentials. On the other hand, the "403 Forbidden" status code signifies that the server understands the request but refuses to fulfill it.

References

Top Articles
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 5600

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.