What is HTTP error 400 and how do you fix it?
Tips and tricks to diagnose and debug a 400 Bad Request error
Most of the time client-server communications occur ceaselessly and effortlessly. However, on occasion you may run into the HTTP 400 error, also known as a Bad Request error.
This error can indicate that a request has not been met successfully, or that the remote server that received the request was unable to interpret it, such as when the request has become corrupted.
Servers usually respond to requests in a specific and often fixed format, and so anything out of the ordinary can result in an error message. To add to the confusion, sometimes the server itself may cause the error, but this is rare.
In Firefox and Safari, these errors usually result in a blank page with no status code. But with Chrome, the browser will show a generic “This page isn’t working” message along with an error code.
Some other common HTTP 400 error messages include:
- Bad Request - Invalid URL
- Bad Request: Error 400
- HTTP Error 400 - Bad Request
- HTTP Error 400. The request hostname is invalid
- Bad Request. Your browser sent a request that this server could not understand
Website owners may also opt to customise their HTTP Error 400 page to ensure reliable hosting services. An example of this is when web servers run Microsoft Internet Information Services (IIS), which can break down the error in more detail, such as “400.3: Invalid If Header”, “400.2: Invalid Depth Header”, “400.1: Invalid Destination Header”, and more.
HTTP error 400 causes
There’s a mixture of problems that can lead to a 400 Bad Request error. Here, we’ll go over five typical issues.
1. Bad URL Syntax
A 400 Bad Request error is usually a client-side error. A good case in point is a URL string syntax error. Incorrectly typed URLs, or URLs that contain backslashes and other invalid characters can garble a request.
For example, the following URL will send you to a valid page.
Access the same URL with an extra “%” in it, and your browser will throw a 400 Bad Request error.
2. Invalid Cookies
Cookies store information on websites you visit and may also record authentication data to speed up log in. If you can’t log into a website you previously visited, it means the cookie containing your log in data is no longer valid. This results in a 400 Bad Request error.
3. Incorrect file size
You may be trying to upload a file that’s too large to a website. The server will fail to fulfill your request and respond with a 400 error message in such a case.
Keep in mind, the hosting provider sets the maximum upload size limit at the server level. For example, the maximum file size limit for WordPress ranges from 4MB to 128MB.
4. Unsynchronized DNS Cache
Browsers read domain names as IP addresses, which are stored locally in the Domain Name System (DNS) cache to improve the browsing experience. A 400 Bad Request error can occur when the DNS data stored locally is out of sync with a website’s registered DNS information during a future interaction.
5. Server error
Servers can cause errors too. To check if there's an issue with the server, try loading a website from a different browser and device. If the website fails to open in Edge, Chrome, Firefox, or IE, it's likely a server-side problem.
How to fix a 400 Bad Request?
It’s hard not to be unfazed by an HTTP error that tells you little about the problem. That said, fixing a 400 Bad Request error takes just a few steps. We’ve put together a few useful tips below to help you find your way out.
1. Recheck the URL
Since a malformed URL is the most common cause of the 400 Bad Request error, make sure there are no typing or syntax errors in your URL. Alternatively, for long URLs, consider using an online URL encoder, which automatically detects non-ASCII characters or invalid characters in a URL, saving you time and effort.
2. Check your internet connection
If you keep seeing a 400 Bad Request on nearly every website you visit, check your internet connection or consult your internet service provider to rule out a poor connection.
3. Clear browser cookies
A website may fail to comply with your request due to old or corrupt cookies. As a quick fix, consider clearing your browser cache and cookies. Repeat this exercise from time to time to avoid running into a 400 Bad Request error.
4. Clear DNS Cache
This works similar to clearing browser cookies and cache, except that it’s locally stored in your computer and may contain outdated information that doesn’t sync with the current webpage. You can clear old DNS information and records from your system within the Command Prompt in Windows and Mac.
5. Compress the file
If you run into an HTTP Error 400 right after uploading a file, try uploading a smaller file. If that works, you may conclude that the initial file exceeded the server limit. The best workaround for uploading a large file is to compress it. Most websites permit zip files that fall under the maximum upload size.
6. Deactivate browser extensions
While this isn’t a common solution for a 400 Bad Request error, some browser extensions may interfere with cookies. Temporarily disabling them might resolve the problem.
7. Restart your system
If you’ve tried all the above fixes and the HTTP Error 400 still continues, you might want to try turning off the system and turning it back on again. Although often derided, rebooting a device is astonishingly capable of solving a range of problems. With the HTTP Error 400, you will want to not only restart your computer but any attached peripherals - including the router.
IBM FlashSystem 5000 and 5200 for mid-market enterprises
Manage rapid data growth within limited IT budgetsFree download
However, if restarting your system does not solve the issue, there is likely a problem with the website server. The cause can be anything from an overheated server room to a data centre power cut. Unfortunately, this means there's nothing further you can do, although there are likely teams of people working to solve the problem. Reporting the problem to the website's administrators could bring you some solace, but they may also provide you with an estimate as to how widespread the issue is, or how it will take to resolve.
Websites such as Down Detector provide a way for the wider community to report problems, and so it's a good idea to share the issue with others.
At the end of the day, HTTP Error 400 is very much like other HTTP errors in the way that its causes are frequently perplexing as well as baffling. In many cases, they can be traced back to a uncomplicated issue, such as expired browser files and cookies, wrongly inserted URLs, or even an incorrect file size.
IT best practices for accelerating the journey to carbon neutrality
Considerations and pragmatic solutions for IT executives driving sustainable ITFree Download
The Total Economic Impact™ of IBM Spectrum Virtualize
Cost savings and business benefits enabled by storage built with IBMSpectrum VirtualizeFree download
Using application migration and modernisation to supercharge business agility and resiliency
Modernisation can propel your digital transformation to the next generationFree Download
The strategic CFO
Why finance transformation propels business valueFree Download