HTTP 400 Bad Request — What It Means and How to Fix It

The HTTP 400 Bad Request status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. This usually means the request message was malformed, syntactically incorrect, or violates protocol constraints.

Last updated: 2026-06-11

RECOMMENDED

Essential Reading: Designing Data-Intensive Applications

The system design bible for software engineers. Learn to build reliable, scalable, and maintainable systems.

View on Amazon →
Status Code 400
Name Bad Request

Common Causes

  • Malformed request syntax (e.g., invalid HTTP headers, incorrect method)
  • Invalid or missing required parameters in the request body or query string
  • Request body too large or exceeding server limits
  • Invalid characters in URLs or headers
  • Security violations (e.g., attempting to inject malicious code)

Code Examples to Handle HTTP 400

curl -I https://httpbin.org/status/400

How to Fix It

  1. Review the request's syntax: Check HTTP headers, method, URL, and body for any malformations or incorrect formatting.
  2. Validate request parameters: Ensure all required parameters are present and that their values conform to expected data types and constraints.
  3. Check server logs: Server-side logs often provide more specific details about why the request was deemed 'bad'.
  4. Reduce request size: If the request body is very large, try sending a smaller request or breaking it into multiple requests.
💡 Example: A user tries to register on a website, but the password field is left empty, which is a required field. The server responds with a 400 Bad Request because the submitted data does not meet the application's validation rules.
🛠️ Developer Tip: Always provide clear and specific error messages in your API responses when returning a 400. This helps clients understand what went wrong and how to correct their request.

Related Status Codes

Frequently Asked Questions

What causes HTTP 400?

HTTP 400 is caused by the client sending a request that the server considers invalid or malformed. This could be due to incorrect syntax, missing required data, or data that doesn't meet server expectations.

How do I fix HTTP 400?

To fix an HTTP 400, you need to examine the request you're sending. Check for correct HTTP syntax, ensure all required parameters are present and valid, and review any server-side error messages for more specific guidance on what's wrong with your request.