What Is a 400 Bad Request Error? Causes and Fixes

Sunucun 4 min read

Short answer: 400 Bad Request is an HTTP error code meaning the server didn’t process your request because it found it malformed or invalid. Most of the time the problem is on the browser side: corrupted or oversized cookies, a mistyped address or a browser extension. The quickest fix is to delete the cookies for that site only and open the page again.

Illustration: What Is a 400 Bad Reque…

What Does 400 Bad Request Mean?

The HTTP standard (RFC 9110) defines 400 as the server being unable or unwilling to process a request because of something it perceives as a client error, such as malformed request syntax or invalid request framing. Codes starting with 4xx point to the client side, and codes starting with 5xx to the server side. So with a 400 error the server is up, but it won’t accept the incoming request.

Most Common Causes

CauseHow to tellFix
Corrupted or oversized cookiesOnly one site, only your browser; the message may say “Request Header Or Cookie Too Large”Delete that site’s cookies
Malformed URLThe address contains spaces, a lone % sign or broken charactersCorrect the address or navigate again from the home page
Browser extensionThe site opens in a private window (extensions off)Turn extensions off one by one to find the culprit
Stale cacheIt started after the site was updatedClear the cache
Server or application sideIt happens for everyone, in every browserThe site owner should check the logs

Step-by-Step Fix for Visitors

  1. Check the address: Look for typos, spaces or extra characters in the URL. If you copied a long link, it may have been copied incompletely.
  2. Delete cookies for that site only: In Chrome, click the icon to the left of the address bar and use Site settings > Delete data. This way you stay logged in on other sites.
  3. Try a private window: If the site opens in a private window, the problem is cookies or extensions.
  4. Clear the cache: In Chrome, press Ctrl + Shift + Delete and clear “Cached images and files”.
  5. Turn off extensions: Temporarily disable ad blockers, VPN and privacy extensions in particular.
  6. Try another browser or device: If the error happens everywhere, the problem is most likely the site; let the site owner know.

Getting the error while uploading a file? Very large files usually return 413 Content Too Large rather than 400, while very large request headers can result in 431 or a 400 on Nginx. Make the file smaller and try again.

For Site Owners: Server-Side Checks

If every visitor sees the error, check the server logs:

# See which requests got a 400 (Nginx access log)
sudo awk '$9 == 400' /var/log/nginx/access.log | tail -n 20

# Error log
sudo tail -n 50 /var/log/nginx/error.log
  • “Request Header Or Cookie Too Large”: Caused by the site writing too many or too large cookies. The lasting fix is to reduce unnecessary cookies; as a stopgap you can raise large_client_header_buffers in Nginx.
  • Application validation: An API or form may return 400 when missing or invalid fields are sent; check the application’s error message and log.
  • Firewall / WAF: A rule may be blocking legitimate requests by mistake; check the WAF logs.
  • Proxy or CDN: If there is a CDN in front, use the response headers to tell whether the error comes from the CDN or the origin server.
# Inside the Nginx http or server block (example value)
large_client_header_buffers 4 16k;

sudo nginx -t && sudo systemctl reload nginx

Codes Often Confused with 400

CodeMeaning
401 UnauthorizedYou need to log in (authentication required)
403 ForbiddenThe request was understood but access isn’t allowed
404 Not FoundThe requested page or file wasn’t found
413 Content Too LargeThe data sent (for example an uploaded file) is too large
429 Too Many RequestsToo many requests were sent in a short time
431 Request Header Fields Too LargeThe request headers are too large

We cover server-side 5xx errors in our 502 Bad Gateway and 504 Gateway Timeout guide. If you want to manage server settings yourself, take a look at our VDS server options.

Conclusion

A 400 Bad Request error is usually caused by corrupted cookies in the browser or a malformed address, and deleting that site’s cookies fixes it. If everyone sees the error, the problem is on the server; check the logs, cookie size, application validation and firewall rules.

Categories

Latest guides