401 Unauthorized is the web equal of a “Restricted Entry” signal at a fancy nightclub. Positive, it might assist you preserve away some unsavory guests. However it could actually additionally flip away reliable clients whereas making you seem like a snob.
Worse nonetheless, 401 errors are sometimes attributable to causes that don’t have anything to do with the customer, making them further irritating to come across. However to not fear! Listed below are just a few easy steps you may take as an internet site proprietor to troubleshoot the 401 error earlier than it begins impacting your web site’s belief.
What’s the 401 Unauthorized Error?
HTTP 401 Unauthorized is a standing code which means a request failed as a result of it lacks legitimate authentication credentials for the requested useful resource. The server sends it with a WWW-Authenticate response header that names the authentication scheme it expects. To repair it, re-enter your credentials, clear stale cookies, or verify the server’s authentication configuration.
What that truly means: 401 Unauthorized is an authentication error, which suggests the web page you are attempting to go to is password-protected and your browser hasn’t equipped legitimate login credentials. This may occur when the consumer enters a unsuitable password or when the browser fails to ship legitimate credentials in any respect.
In fact, 401 errors may also be false positives, which means that the error can happen even when the customer has the suitable credentials to log into an internet site. It might even happen when the net web page isn’t presupposed to be password-protected in any respect. For instance, it may be attributable to a jittery firewall, a difficult plugin, or an uncooperative extension added to your web site.
It’s possible you’ll discover the 401 error as one in every of these messages popping up in your browser window:
- 401 Authorization Required
- 401 Unauthorized
- HTTP 401 Error – Unauthorized
- Entry Denied
- HTTP Error 401
401 vs. 403 vs. 407: which error do you even have?
Earlier than troubleshooting, affirm you’re an actual 401 and never one in every of its neighbors. The quick model: a 401 means the server doesn’t know who you might be, whereas a 403 means it is aware of precisely who you might be, and the reply remains to be no. Per MDN’s 403 reference, “authenticating or re-authenticating makes no distinction” for a 403.
| Standing code | What it means | Will logging in repair it? |
|---|---|---|
| 401 Unauthorized | The request lacks legitimate authentication credentials — lacking, expired, or unsuitable. | Sure. Retry with legitimate credentials. |
| 403 Forbidden | The server understood the request however refused it, often as a result of your account lacks permission. | No. You want permissions modified, not one other login. |
| 407 Proxy Authentication Required | A proxy between you and the positioning (frequent on company networks) needs credentials — the web site itself isn’t asking. | Sure, however authenticate with the proxy by way of its Proxy-Authenticate problem. |
| 400 Dangerous Request | The request itself is malformed, so the server received’t course of it. | No. The request has to vary earlier than the server will settle for it. |
One lure value naming: should you’re behind a company proxy or VPN, an authentication immediate could also be a 407 from the proxy, not a 401 from the web site. Examine the standing code in your browser’s developer instruments earlier than blaming the positioning.
What causes a 401 unauthorized error?
401 errors happen when an online browser has hassle authenticating the customer’s login credentials with the web site’s server. Listed below are just a few frequent the explanation why which may occur:
- Error or typo within the web site’s URL.
- Outdated cookies or browser cache.
- IP handle restrictions on website entry.
- Errors in server configuration.
- Incompatible plugin or web site theme.
- Incorrect login makes an attempt by the consumer.
401 errors are usually client-side errors, which means they will usually be fastened by clearing your browser’s cookies or inputting the proper password. Nonetheless, server-side points like plugins and firewalls may also trigger these errors, making it essential for website admins to pay attention to potential conflicts.
However these are all surface-level explanations. If you wish to know what causes a 401 error, you have to perceive how authentication works in internet improvement.
When a consumer (i.e., an online browser) requests entry to a protected useful resource on an internet site, the web site will want the consumer to supply some type of legitimate authentication. These credentials might be within the type of API keys, a username and password, digital certificates, or one thing else, relying on the authentication scheme utilized by the positioning.
The web site then processes the authentication credentials to confirm their validity. This might contain checking the credentials towards a saved database of customers and passwords, contacting an exterior authentication supplier, or performing another type of validation.
If the authentication is profitable, it returns a 200 standing code, and the web site will generate a session token for the consumer. This identifies the authenticated consumer and tracks the consumer’s interactions inside the web site. The session token is usually saved in a cookie within the consumer’s browser or as a header in any subsequent requests.
Nonetheless, if the authentication is unsuccessful, the web site will return an HTTP error message, such because the 401 error code. The 401 error message sometimes features a WWW-Authenticate header, which explains the right way to authenticate with the server within the consumer’s browser. This header can embody extra context in regards to the 401 error, resembling the kind of authentication required (e.g., Fundamental, Digest, or OAuth).
Easy methods to repair the 401 unauthorized error
401 entry management errors are fairly frequent when logging right into a membership website or accessing a protected internet web page. Fortunately, they’re additionally very straightforward to repair more often than not. Right here are some things you are able to do to handle this error, each as an internet site customer and an online administrator:
Shopper-side options
401 error pages are typically attributable to client-side points like login credentials and even the net browser used to entry your web site’s password safety system. These may be fastened with just a few easy steps from the customer’s finish:
- Examine Consumer Credentials: Be sure you entered the proper username and password mixture. Double-check your authentication credentials for the slightest typo. Keep in mind, usernames and passwords are case-sensitive.
- Clear Browser Cookies: If the web site makes use of cookies for authentication, the error could also be due to invalid or expired cookies. Usually, cookies have an expiration date or simply expire when the browser is closed. For those who’re having hassle accessing an internet site, clear searching knowledge by following the directions on your particular internet browser to assist resolve the difficulty.
Cookies
Cookies are items of knowledge despatched to a consumer’s laptop or cellular gadget by an online server. They’re then saved on the consumer’s gadget. Cookies can be utilized for authentication, identification of a consumer session, personalization of internet content material, or accumulating details about the usage of an internet site.
- Confirm URL: Make sure that the URL you’re making an attempt to entry is appropriate and updated. A mistyped URL often returns a 404, however a URL that factors right into a password-protected space of a website can return a 401. For those who’re following a hyperlink from one other web site, it’s fairly attainable that the hyperlink is utilizing the unsuitable URL.
- Too Many Makes an attempt: Some websites briefly lock logins after repeated failed makes an attempt, so wait a couple of minutes earlier than retrying. True fee limiting has its personal standing code, although — per MDN, servers sign it with a 429 Too Many Requests response, not a 401.


DNS flushing
What’s DNS?
The Area Title System (DNS) protocol retains data of which domains correspond to particular IP addresses. This technique allows you to browse the net by typing in common URLs as a substitute of IP addresses.
DNS caches assist enhance loading velocity and web site efficiency when searching the web, however stale or outdated entries can ship your browser to the unsuitable (or an outdated) server, which might reply with surprising errors. Flushing (clearing) your DNS cache is a fast, innocent technique to rule this out, and it may be completed just a few alternative ways:
Home windows: To flush your DNS on Home windows 10/11, comply with these steps:
- Open the Command Immediate by urgent Home windows+R and typing “cmd” (with out quotes) into the Run dialog field.
- Now kind within the command “ipconfig/flushdns” inside Command Immediate.
- In case you are a Home windows PowerShell consumer, you are able to do this by opening PowerShell and typing in “Clear-DnsClientCache” (with out quotes).
- This can flush the DNS and clear all of the data from the native DNS cache.
macOS: For those who’re utilizing a MacBook or iMac, you may flush your DNS cache utilizing Terminal.
- Open Terminal in your Mac by utilizing Highlight Search or urgent Command+Area and typing Terminal into the search field.
- Inside Terminal, kind in “sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder” (with out quotes).
- Your DNS cache has now been flushed in your Apple laptop.
Google Chrome: For those who’re utilizing Google Chrome, the browser has its personal DNS cache that’s impartial of the working system (Home windows or Mac). To clear Chrome’s DNS cache:
- Kind “chrome://net-internals/#dns” into the handle bar.
- Now, click on on the “Clear host cache” button to clear your DNS data.

Server-side options
If the customer’s credentials and browser take a look at, the issue lives in your server. Work by means of these checks so as.
Fixing a 401 error attributable to WordPress plugins
Plugins are a staple for WordPress web sites, however they will typically additionally trigger errors if configured improperly. This may occur when the plugin comprises code that creates an internet site safety difficulty or conflicts with the platform’s core performance.
So, what can a website admin do to repair this difficulty? Properly, step one is to determine which plugin or plugins are inflicting the difficulty. Often, this may be completed by disabling every plugin one after the other and checking if the error nonetheless seems. As soon as the plugin inflicting the difficulty is recognized, you may both replace, reconfigure, or completely take away it. Widespread culprits might embody:
- CDN providers like Cloudflare and KeyCDN.
- Internet firewalls like Sucuri and Wordfence.
- Poorly constructed WordPress themes.
Observe these easy steps to allow or disable plugins in your WordPress website:
- First, log in to your WordPress dashboard.
- Click on on the “Plugins” possibility within the left-hand menu.
- Discover the plugin you need to allow or disable and click on on the “Activate” or “Deactivate” button beneath the plugin title.
- If you wish to disable a number of plugins without delay, verify the field subsequent to every plugin and choose “Deactivate” from the “Bulk Actions” drop-down menu.
- If you wish to allow a number of plugins without delay, verify the field subsequent to every plugin and choose “Activate” from the “Bulk Actions” drop-down menu.
In some circumstances, it’s also attainable to repair the difficulty by disabling or reconfiguring particular settings inside a plugin. For instance, in case your web site makes use of a caching plugin, it’s value making an attempt to clear the cache and verify if the error nonetheless seems.
In just a few uncommon circumstances, 401 errors may result from a server error. You’ll find out extra about this by your WWW-Authenticate Header.
The WWW-Authenticate Header is a response header despatched by the server that comprises info on the authentication strategies supported by the positioning. This header helps the consumer’s browser resolve which authentication protocol to make use of when requesting knowledge from the server.
The header can also be used to ship further details about the authentication course of. This will likely embody the area being protected by the authentication scheme, or the algorithm utilized by the server.
Right here’s what the change seems like on the wire, utilizing the instance from MDN’s 401 reference:
GET /admin HTTP/1.1
Host: instance.com
HTTP/1.1 401 Unauthorized
Date: Tue, 02 Jul 2024 12:18:47 GMT
WWW-Authenticate: Bearer
Studying it line by line: the consumer asks for /admin with out sending any credentials. The server solutions 401 and makes use of WWW-Authenticate: Bearer to say “this useful resource wants a bearer token.” Resend the request with a legitimate Authorization header, and the 401 goes away.
To verify the WWW-Authenticate Header, open Chrome, navigate to the URL inflicting the 401 error, and right-click wherever on the web page. From the drop-down menu, choose “Examine”. This can deliver up the Developer Instruments window.
Choose the Community tab as soon as contained in the Developer Instruments window. Right here, you’ll see all of the requests the browser sends when loading the web page. If the response from the server comprises a WWW-Authenticate header, it is going to be seen on this tab.
By inspecting the WWW-Authenticate header, you will get a greater understanding of the authentication course of utilized by the server. Subsequent, verify that the response was despatched and determine what authentication scheme was used to ship it. That’ll assist you slender down the issue earlier than in search of a selected answer. Listed below are just a few authentication schemes discovered within the WWW-Authenticate Header, together with descriptions of how they work, for reference:
- Fundamental: This scheme makes use of a base64-encoded username and password separated by a colon. That is thought of the least safe authentication methodology and will solely be used over HTTPS.
- Digest: This scheme makes use of a challenge-response protocol to authenticate shoppers. The server sends a nonce worth to the consumer, which the consumer makes use of to create a response primarily based on the username, password, and request info.
- Bearer: This scheme is used for OAuth 2.0 authentication. The consumer receives a token from the server, which it makes use of to authenticate subsequent requests.
- Negotiate: This scheme is used for Kerberos authentication.
- AWS4-HMAC-SHA256: This authentication scheme is used to authenticate requests to Amazon Internet Providers (AWS) utilizing an AWS entry key and a secret entry key.

Fixing a 401 error from an API or token
Getting the 401 from an API reasonably than an online web page? Suspect the token first. Three checks resolve most circumstances:
- Examine expiry and revocation: OAuth 2.0 entry tokens expire, and below RFC 6750 an expired or revoked bearer token is rejected with a 401 and an “invalid_token” error code. Refresh the token or request a brand new one, then retry.
- Confirm the Authorization header: credentials should be despatched within the format the scheme expects (for Bearer auth, that’s “Authorization: Bearer
”). A lacking scheme title or stray whitespace is sufficient to earn a 401. - Match the scheme: examine your request towards the WWW-Authenticate problem within the 401 response. It names the scheme (and infrequently the realm) the server really accepts.
.htaccess file
For those who’re experiencing a 401 error in your web site, one attainable trigger might be a problem along with your .htaccess file. The .htaccess file is a configuration file utilized by Apache internet servers to manage entry to your web site’s directories and recordsdata. Right here’s the right way to verify your .htaccess file for causes of a 401 error:
- Connect with your web site’s server utilizing an FTP consumer or file supervisor.
- Navigate to the listing the place your .htaccess file is positioned. That is often the basis listing of your web site.
- Obtain a duplicate of your .htaccess file to your laptop.
- Open the .htaccess file in a textual content editor (like Notepad++) and search for any traces that specify entry controls or authentication necessities. Particularly, you’ll need to search for the next parameters: AuthUserFile, AuthName, AuthType, and Require.
- Examine that the entry controls or authentication necessities specified within the .htaccess file match the settings you propose to make use of on your web site. For instance, when you have not too long ago up to date your web site’s authentication mechanism (AuthType), you might must replace the corresponding settings in your .htaccess file as nicely.
- Save the modifications to your .htaccess file and add it again to your web site’s server.
- Take a look at your web site to see if the 401 error has been resolved.
What a lingering 401 does to your search engine optimization
Right here’s the half that makes velocity matter: search engine crawlers don’t have your password. If pages that ought to be public begin returning 401 (as a result of a firewall misfire or staging password safety left switched on), Googlebot will get the identical locked door your guests do. Google solely indexes a web page after it could actually crawl and course of its content material, per Google’s Web page indexing report documentation, so a web page serving 401s can’t keep eligible for search outcomes.
You do get a grace interval. Google notes that when a URL is unavailable, it “will most likely proceed to attempt crawling that URL for some time.” Use that window: open the Web page indexing report in Search Console, which flags the indexing issues Google hit whereas crawling your website, and repair any unintended 401 earlier than the retries cease.
HTTP response codes supply little context on their very own, which makes them troublesome to navigate with out the correct technical help. It’s a part of the rationale why DreamHost gives 24/7 assist that can assist you troubleshoot downtime in your web site and area.
For those who’re having hassle diagnosing or fixing a 401 error in your web site, you may attempt contacting your internet hosting supplier for assist. It’s additionally attainable to contract a technical skilled, resembling a internet developer, for assist with the difficulty.
401 errors may be jarring for the top consumer, however they’re usually a straightforward repair. For those who’re contacted by somebody unable to entry your web site as a result of this error, stroll them by means of the frequent client-side options earlier than trying into any potential server points, resembling WordPress plugins or the WWW-Authenticate header. For those who’re nonetheless having hassle, you may at all times usher in some technical assist to diagnose the difficulty.
FAQs in regards to the 401 unauthorized error
What does “401 – Unauthorized: entry is denied as a result of invalid credentials” imply?
It’s a long-form model of the usual 401 error: the server rejected the request as a result of it lacked legitimate authentication credentials. Double-check your username and password, clear the positioning’s cookies, and check out once more. The message doesn’t imply your account was banned.
Is a 401 error the identical as a 403 Forbidden error?
No. A 401 means you aren’t authenticated: credentials are lacking or invalid, so logging in accurately can repair it. A 403 means the server is aware of who you might be and nonetheless refuses. Per MDN, re-authenticating makes no distinction for a 403.
What does 401 Authorization Required imply?
It’s one other label some servers use for a similar HTTP 401 standing: the web page is protected, and the server wants legitimate credentials earlier than it can reply. The fixes are similar: confirm the URL, re-enter your credentials, and clear cookies for the positioning.
Is a 401 error my fault because the customer?
Not at all times. Unsuitable passwords and expired cookies are visitor-side causes, however misconfigured plugins, firewalls, and .htaccess guidelines on the server can return a 401 even when your credentials are appropriate. If different individuals report the identical error, the issue is sort of definitely server-side.
Do 401 errors harm search engine optimization?
They’ll. Search engine crawlers can’t log in, so a public web page that returns 401 can’t be crawled or listed. Unintended 401s floor in Google Search Console’s Web page indexing report — repair them rapidly to maintain affected pages eligible for search outcomes.
Did you get pleasure from this text?








