Thursday, April 30, 2020

What Is 401 Error Code and How to Fix It on WordPress (Quick Guide)

Trying to access a website only to be met with a 401 error code? This could be happening on your own WordPress website or it could be happening on someone elses site that youre trying to visit.If your WordPress site is showing the 401 error code to other visitors, its important to fix the problem so that your visitors can enjoy your site. And if youre experiencing the 401 error code when you visit someone elses site, youll want to understand the problem so you know whats happening. What does the 401 error code mean?A 401 Unauthorized error is an HTTP status code indicating that the server received an unauthenticated request. 401 error code responses are most often generated because of invalid credentials for a particular page or destination on your website. This status is typically sent with a WWW-authenticate header that contains information on how to authorize properly.In human terms, this basically means that your client (e.g. your web browser)  isnt able to authenticate itself with the server and, as such, cannot view the resource. For example, a specific page might require a valid username and password to view.The 401 error code, like other error codes in the 400-range, means theres a problem on the  client-side AKA the problem lies on your web browsers side (or another client), rather than the website youre trying to visit.401 error vs 403 errorPeople often confuse a 401 error with a 403, but the two are different. A 403 error means access to the page is  forbidden, whereas a 401 error just means theres a problem with authenticating access to the page. That is, a 401 means access is not necessarily forbidden, the server just cannot authenticate the request to grant access.401 error code variationsThe exact message that indicates a 401 error code varies depending on the server, but here are the typical 401 error code variations that youll see:401 UnauthorizedAuthorization RequiredAccess DeniedHTTP Error 401 UnauthorizedWhat causes the 401 error code ?Here are some common causes of the 401 error code:Incorrect URL   sometimes the 401 error code is because of the wrong URL. Make sure that the URL for the site you want to access has been entered correctly.Invalid login credentials   some pages of a website require you to login in order to access the information. If you’re not logged in, you will very likely get a 401-error. Make sure that the login credentials you are entering are accurate.False login requirement   this occurs rarely but, in some cases, a website that should not require a login will still show a login page. This indicates an issue on the admin side and will often throw up a 401-error.DNS errors   occasionally, domain name system failures may result in a 401 response. DNS malfunctioning is less common.Security/firewall issues   some WordPress security plugins or firewalls can cause a 401 error if they detect malicious activity.Plugin issues   a WordPress plugin on your site might be triggering th e 401 error code.How to fix the 401 error code on WordPressOften, 401-error codes can be fixed by simply hitting the refresh button. If refreshing your page doesn’t work, try the following fixes:1. Check the URL for errorsIt is possible that a 401 error occurs because you have typed the URL incorrectly or the login URL has been changed. Alternatively, you may have clicked on an outdated link in your web browser. In cases where a page no longer exists, the server might show a 401 code. Check the URL for spelling mistakes. You can also use a search engine to find the correct URL of the webpage you are trying to access.2. Clear browser cache and cookiesYour browser’s cache helps improve your overall surfing experience by decreasing the loading time of websites. To do this, browsers store local copies of the content you visit most frequently. Your browser’s cache can sometimes overlap with the live version of your application, resulting in a 404 error code.To fix th is error, just clear the browser’s cache.Similar to the cache, there are HTTP cookies which are basically tiny pieces of stored data. Invalid and/or corrupted cookies can cause an authentication error. Clear the cookies and try to open the page again.3. Deactivate your WordPress pluginsBecause WordPress plugins can alter how your site functions, theyre a typical cause of the 401 error code on WordPress.In the case of WordPress security plugins, sometimes the plugin intends to do this. For example, some plugins will lock down your login page if the plugin thinks youre under attack, which can trigger the 401 error code when you try to open your login page. Or the firewall in a plugin like Wordfence might cause the issue.In this case, once you figure out the issue by deactivating the plugin, you can reach out to the plugins support to understand the issue.Other times, it could be an unintended compatibility issue.To figure out which plugin is causing the 401 error, try deactivat ing all of the plugins at your site and reactivating them one-by-one. Or, if the error only appeared after you installed a new plugin, try deactivating that plugin first.4. Remove server-level password protectionIf youre using htaccess/htpasswd to protect parts of your WordPress site with an extra username/password, try deactivating this extra password protection.Many web hosts also give you a tool to control such passwords from cPanel. Look for a tool named something like:Password protect directoriesDirectory privacy5. Flush your DNSIn rare cases, DNS errors can cause the server to show a 401-error code on your browser. To fix this, you need to flush your DNS. Although this is a fairly unusual cause, it is quite simple to repair.For Windows users:Log in to your computer as an administratorOpen a â€Å"search† windowType in CMD.exe in the search field to open Command PromptEnter this little code in the CMD interface: â€Å"ipconfig/flushdns†For macOS users:Open the Com mand TerminalEnter this code in terminal interface: â€Å"sudo killall -HUP mDNSResponder†6. Try waitingLike security plugins, some WordPress hosting companies will temporarily block your IP if they think youre doing something malicious e.g. entering the wrong password. In this case, you can try waiting to see if that fixes the issue, as sometimes your site is only locked down for a short period of time.Additionally, many WordPress websites need regular downtime for maintenance. If you’re seeing a 401-error on someone elses site, there may be maintenance or construction going on at the backend causing temporary login issues. Try giving the admins some time and logging in a few minutes later.ConclusionA 401 error indicates a client-side problem with authentication. That is, your web browser is having issues authenticating itself with your WordPress sites server.Before you start digging into any in-depth troubleshooting, try a few quick fixes first. Make sure that the U RL you’re using is correct, and don’t forget to clear your browser’s cache and cookies. Seeing a 401 error code on your #WordPress #website? Here's what it means and how to fix it 🔠¨ Click To Tweet Also consider any security tools you may be using on your site, as well as any server-level passwords you might have added, like a password via htaccess and htpasswd. You can also try deactivating your plugins.Do you have any questions about the 401 error code? Let us know in the comments!Free guide5 Essential Tips to Speed Up Your WordPress SiteReduce your loading time by even 50-80% just by following simple tips.