A visitor clicks a link to your website and gets "401 Unauthorized", "401 Authorization Required" or a small browser window asking for a username and password. They did not expect a login, so most of them close the tab. If that page should be open to everyone, every visitor who lands on it is lost until you find the cause.
The short answer: a 401 error means the server wants proof of who the visitor is before it shows the page, and it did not get a login it accepts. Sometimes that is exactly what you want, on a page for members or clients. Sometimes it is a setting, a password or a link that points to the wrong place. If you only want the short definition, read what 401 Unauthorized means. This guide is about fixing it: how to tell a 401 apart from similar errors, the usual causes, and a checklist you can work through without a developer.
What a 401 error means for your website
Every time a browser asks for a page, the server answers with a status code. A 401 is the server saying: show me a valid login first. The page exists and the server works, but this request came without a username and password, or with ones the server does not accept.
You may see it written in different ways, depending on the server and the browser:
- 401 Unauthorized (in British English also "401 Unauthorised")
- HTTP Error 401 or Error 401
- 401 Authorization Required
- 401 Not Authorized or Access denied
- A browser popup that asks for a username and password before anything loads
All of these mean the same thing. The question to answer is whether the page should ask for a login at all.
401, 403, 404 or 500: which error do you have?
These codes look alike, but each one points to a different fix:
- 401 Unauthorized: the server needs a login and did not get a valid one. Logging in with the right details can solve it.
- 403 Forbidden: the server understood the request and still says no. Logging in does not help, because this visitor or address is not allowed in. Read what 403 Forbidden means.
- 404 Not Found: there is no page at that address. See what a 404 error is and how to fix it.
- 500 Internal Server Error: the server broke while building the page. See how to fix a 500 internal server error.
The usual causes of a 401 error
The page is protected on purpose
A client area, a price list for partners, an admin area or a test copy of your site often sits behind a password. A visitor without the password gets a 401 or a login screen. That is correct behaviour. It only becomes a problem when public links, your menu or search results send ordinary visitors there.
Wrong or changed login details
A typo, Caps Lock, the wrong account or a password that was changed recently all lead to a 401. Browsers also save old passwords and fill them in again, so a visitor can keep sending the old password without noticing.
An expired session or old cookies
After someone logs in, the site remembers them for a while with a cookie. When that session runs out, or the cookie is damaged, the next page they open may answer with a 401 even though they were logged in a minute ago.
A plugin, firewall or hosting rule
Security plugins, firewalls and hosting control panels can all put a password on a page or a whole folder. A common case: the site was built behind a server password while it was not finished, went live, and the password was never removed. Another: a firewall rule meant for the admin area also covers public pages.
A link or redirect that points to a protected address
After a site move or a menu change, a link or a 301 redirect can send visitors to an old test site, an admin address or a members page. The visitor followed a normal link and ends up at a login they cannot pass.
How to fix a 401 error, step by step
Work through these checks in order. Most 401 problems are solved in the first five.
- Decide whether the page should be private. If it is meant for members or clients only, the 401 is doing its job: make sure public links do not point to it. If it should be public, continue.
- Open the page in a private browser window. You are then logged out, with no saved cookies, exactly like a new visitor. If the 401 only shows for you and not in the private window, the problem is your own session or saved password.
- Check the address. Look for typos, an extra folder like /admin or /account, or an address of an old test site. Then check the link or menu item that sent visitors there.
- Log in again with the right details. Check Caps Lock and the account name. If you are not sure of the password, use the "forgot password" link and set a new one.
- Clear the cookies for your site, then log in again. This removes an expired session or a damaged cookie.
- Undo the last change. Think of a password you added to a page, a new plugin, a new firewall or security setting, or a move to another server. Turn it off or set it back, and test the page in a private window.
- Follow the redirects. Open the old address and see where you end up. If a redirect leads to a protected page, point it to the right public page instead.
- Check for a server password. In your hosting control panel, look for password protection on folders (often called directory privacy or protected directories). Remove it from the parts of the site that should be public.
Still stuck? Ask your hosting provider or developer, and give them: the exact page address, the time you saw the error, whether it also happens in a private window, the exact message, and the last change made to the site. With those five details they can usually find the rule that blocks the page.
Keep protected pages out of search results
Search engines cannot log in, so they treat a page that returns a 401 as a page they cannot use. For a private page that is fine, but tell search engines to skip it: mark it as not to be indexed and leave it out of your sitemap. For a page that should be public, fix the 401 first, then ask for the page to be checked again in Google Search Console. A short problem has little effect, but a public page that keeps asking for a login can drop out of the results.
How WEMASY handles login and protected pages
In WEMASY your pages, your webshop and your publishing live in one system, so you set access in one place and you can see what a visitor sees before you publish.
- Password-protected pages. In the page settings, the Security tab has "Secure page with password". Visitors without the password see the public side of the page, where you place a login block, and the protected content shows after they enter the right password. One password is shared with everyone who may see the page; change it to stop access for people who have the old one. The steps are in password-protected pages.
- A login area for your customers. When you turn on customer accounts for your webshop, WEMASY creates the account, login, register, forgot password, reset password and verify email pages, and adds a Login or Register link to your header. Guests can still buy without an account. See customer accounts.
- Locked out of your own dashboard? You can set a new password with resetting your password or log in with a login link sent to your email.
Changes to page access go live when you publish your website, and a protected page is best kept out of search results with "Do not index in search engines" on its SEO tab.
Frequently asked questions
What does a 401 Unauthorized error mean in plain words?
The server wants to know who the visitor is before it shows the page, and it did not get a username and password it accepts. The page exists and the server works; only the login is missing or wrong.
Is a 401 error the visitor's fault or my website's?
It can be either. A visitor who types the wrong password or whose session expired gets a 401 for a good reason. If visitors get a 401 on a page that should be public, the cause is on your side: a password, a plugin or hosting rule, or a link or redirect that points to a protected address.
What is the difference between a 401 and a 403 error?
A 401 means the server needs a valid login and did not get one, so logging in can solve it. A 403 means the server understood the request and refuses it anyway, so logging in does not help.
Why do I get a 401 error even with the right password?
Usually because of an expired session or an old cookie, a password the browser saved before it was changed, or logging in to a different account than the page expects. Open the page in a private window, log in again, and clear the cookies for your site if it keeps happening.
Can a redirect cause a 401 error?
Yes. If an old address redirects to an admin page, a members page or an old test site, visitors who follow a normal link end up at a login they cannot pass. Open the old address, see where you land, and point the redirect to the right public page.
Does a 401 error hurt my Google ranking?
Search engines cannot log in, so they cannot use a page that returns a 401. For private pages that is fine; keep them out of search results on purpose. If a public page keeps returning a 401, it can drop out of the results until you fix it and ask Google to check it again.