When a website doesn’t load, it’s just annoying. however, it’s important to understand why this happened so you know how to fix it.
The 4xx family of status codes is the one we are investigating here as it relates to invalid or corrupt requests from the client. Specifically, we’ll take a closer look at the 400 Bad Request Error: what this error means, what causes it, and some specific troubleshooting steps.
- what is 400 Bad Request Error?
- what causes 400 Bad Request Error
- 400 Bad Request Error – what does it look like?
- how to fix 400 bad request error
watch our video guide to fix 400 errors:
what is a 400 bad request error?
A 400 bad request, also known as a 400 error or 400 http error, is perceived by the server as a generic client error and is returned when the server determines that the error does not fall into any of the other status code categories.
The key concept to understand here is that the 400 Bad Request error is something to do with the request being sent by the client before it is processed by the server.
the internet engineering task force (ietf) defines the 400 bad request as:
Status code 400 (bad request) indicates that the server cannot or will not process the request due to something perceived as a client error (for example, malformed request syntax, missing request message frame). valid or misleading request routing).
what causes the http 400 bad request error
There are several root causes that can trigger the 400 Bad Request error, and even if this error isn’t specific to any particular browser or operating system, solutions vary slightly.
1. url string syntax error
http 400 error can occur due to a misspelled url, malformed syntax, or a url that contains illegal characters.
this is surprisingly easy to do by mistake and can happen if a url has been encoded incorrectly. The following link is an example of a url that contains characters that the server will not be able to process, thus triggering a 400 bad request error.
note the extra % character immediately after the word misform in the url. a correctly encoded space must be %20 and not %%20. this is how the result looks like in the chrome browser.
an illegal character can also trigger a 400 bad request error. the following url contains a { character, which is not allowed. therefore, it results in the same type of error.
2. corrupted browser cache & cookies
Even if the url is 100% correct, the 400 Bad Request Error can still occur due to corrupted files in the browser cache or issues with expired or corrupted browser cookies.
You may have encountered a 400 Bad Request error when trying to access the admin area of your wordpress site some time after your last login. we did not successfully authenticate you as a valid user with administrator privileges. this will result in the connection being refused and triggering a 400 bad request error.
3. dns lookup cache
400 bad request can occur when locally stored dns data is out of sync with registered dns information.
all domain names are alias ip addresses. You can think of an IP address as a phone number that “always calls” a specific server you want to connect to. When you visit a website for the first time, a process called “name resolution” takes place, and that’s when the domain name resolves to the specific IP address of the server.
To speed things up, these details are stored locally on your computer in the local dns cache, so the name resolution process doesn’t have to be done for every visit to a given website. this is similar to how the browser cache works for html, css, javascript, media, and other files.
4. file size too large
A 400 Bad Request can also occur when you try to upload a file to a website that is too large for the upload request to complete. this is strictly related to the file size limit of the server and will vary depending on how it has been configured.
Until now, we have focused on the 400 Bad Request error being triggered only due to client-side issues.
5. generic server error
This error can also sometimes be triggered by server-side issues. specifically, a 400 status code could indicate a general problem with the server, a server crash, or other unspecified temporary problems.
If this happens when trying to connect to a third-party website, it’s really out of your control and your best bet is to try refreshing your browser and check at regular intervals to see if the site owners have fixed the problem.
One thing you can do to verify that the problem is server-side is to try loading the website in different browsers. if you want to go the extra mile, try it on a completely different machine/device to rule out system-specific issues.
When you are unable to connect to the site through other browsers, computers, operating systems, or other devices, it is likely a server-side issue. If you wish, you can contact the owner of the site and let them know what operating system, browser, and versions you were using when you experienced the problem.
400 bad request error – what does it look like?
Most of the time, a 400 Bad Request is related to client-side issues. We already saw what a 400 bad request error looks like in the chrome browser.
But what about the other browsers?
400 bad requests in firefox
400 Bad Request in Safari
400 Bad Request in Microsoft Edge
As you can see, all browsers return a generic and unhelpful 400 status code message. It seems you’re pretty much left alone for finding a solution to the problem. In Firefox and Safari, it’s not even clear a 400 Bad Request error has occurred at all as the browser window is completely blank!
Fortunately, we’ve put together a series of simple steps you can take to fix the 400 Bad Request Error. Let’s take a closer look at each of these in the next section!
how to fix 400 bad request error
Complete the steps in this section to help diagnose and correct a 400 Bad Request.
Proposed solutions include:
- 1. check the submitted url
- 2. clear browser cache
- 3. delete browser cookies
- 4. file upload exceeds server limit
- 5. clear dns cache
- 6. disable browser extensions
Before we dive into the different ways to fix the 400 Bad Request error, you may notice that several steps involve flushing the locally cached data.
It is true that if your computer did not cache any files or data, there would probably be significantly fewer problems with connection errors. however, the benefits of file/data caching are well documented and the web browsing experience would certainly suffer if browsers did not use caching techniques.
It all comes down to a compromise between optimization and user experience, where websites try to load as fast as possible, but can occasionally be prone to errors like a 400 Bad Request without warning.
1. check the url sent
since this is one of the most common reasons for a 400 bad request error, let’s start with an obvious culprit, the url string itself. it can be very easy to include unwanted characters in the url by manually entering it into the browser.
verify that the domain name and the specific page you are trying to access are spelled and spelled correctly. also, make sure they are separated with forward slashes. if the url contains special characters, make sure they are properly encoded and are legal url characters.
for long urls, you may find it easier and less error prone to use an online url encoder/decoder. these kind of utilities should also be able to automatically detect illegal characters in the url.
once you are sure the url is correct, try to access it again in the browser. If you’re still getting the 400 Bad Request error, it’s time to clear some cache!
2. clear browser cache
If any locally stored website files have become corrupted, this may cause a 400 Bad Request error to be returned instead of the expected website content.
This includes all the types of files a website needs to function properly, such as:
- html
- javascript
- text/settings files
- css
- media (images, videos, audio)
- data files (xml, json)
These files are stored locally on your computer by your browser when you visit the website for the first time.
To fix this, you need to clear your browser’s cache.
in chrome, click the three dots icon in the right corner and select more tools > clear browsing data in the pop-up menu.
This will display the Clear browsing data window. In here, you’ll want to make sure the Cached images and files option is checked and then click on the Clear data button to clear the browser cache.
You can also choose to delete recent files for a specific time range via the time range dropdown menu. however, to ensure that all potentially corrupted files are removed, we recommend deleting all locally stored files by selecting the all the time option.
If you’re using an alternative browser, check this guide for clearing the browser cache for all the major browsers (Mozilla Firefox, Safari, Internet Explorer, Microsoft Edge, Opera).
3. clear browser cookies
If clearing your browser’s cache didn’t work, then it’s also time to delete your cookies. a single website can use dozens of different cookies. if just one of them expires or becomes corrupted, it may be enough to trigger a 400 bad request.
To clear cookies in chrome, open the clear browsing data window by clicking the icon with the three dots in the upper right corner and select more tools > clear browsing data in the pop-up menu.
make sure cookies and other site data is checked and select all the time for the date range option to remove all cookies from the current website .
Once done, try loading the website which returned the 400 Bad Request error again. Assuming the site uses cookies, clearing them out from your browser could fix the issue as it’s often associated with corrupt or expired cookies.
To clear cookies in non-chrome browsers, read this guide here.
4. file upload exceeds server limit
If you are trying to upload a file to a website that exceeds the server’s file size limit, you will encounter a 400 Bad Request error.
You can test this by uploading a smaller file first. if it succeeds, the initial file is probably too large and you’ll need to find some way to shrink it before reloading.
This will depend on the type of file you are trying to upload, but there are many resources available online that can help you compress large image, video, and audio files.
5. clear dns cache
another common cause of a 400 bad request is when local dns lookup data becomes corrupted or stale.
local dns data is not stored by the browser but by the operating system itself. we have put together a detailed guide to clear dns cache for windows and macos operating systems.
6. disable browser extensions
If you have browser extensions installed that affect website cookies, these could be the culprit here. try temporarily disabling them to see if it makes a difference before trying to connect to the website again.
You may not have considered this to be a problem, but it’s certainly worth a try if you’ve exhausted all other options.
summary
If you experience a 400 Bad Request error, there are several things you can do to try to fix the problem.
In the vast majority of possible scenarios, a 400 Bad Request is either a client-side issue caused by the request being sent to the server, or a local caching issue. The solutions described in this article are easy to implement by anyone with minimal technical knowledge. you should be able to get your website back up and running in no time!
Occasionally, however, a 400 Bad Request status code could indicate a generic server problem. this can be quickly diagnosed by testing the given site on different devices. If you suspect a server-side error, there’s not much you can do other than keep trying to load the site at regular intervals and report it to the site administrator.