400 Bad Request

400
Bad Request
!
?

Example HTTP Response

HTTP Response
HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error": "Invalid request format"}
Common Causes
  • Malformed JSON in request body
  • Missing required fields
  • Invalid query parameters
Technical Details

What does this mean?

Huh? The server is scratching its head because your request doesn't make sense. Like ordering a pizza with negative toppings.

Technical Definition

The server cannot process the request due to client error (malformed syntax, invalid request framing, etc.).

RFC Says

"The 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 (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)."

Plain English:

The request is malformed or invalid - there's something wrong with how you structured the request itself. Use this for syntax errors like invalid JSON, malformed headers, or completely missing required data.

Common Misinterpretation

400 is for syntax/formatting errors, not validation errors. If the request is syntactically valid but the data fails business logic validation (e.g., invalid email format, date in the past), use 422 (Unprocessable Entity) instead. 400 means 'I can't even parse your request,' while 422 means 'I understand your request but the data doesn't make sense.'

Code Snippets

Ready-to-use code for returning this HTTP status in your application:

Node.js
// Express.js
app.get('/example', (req, res) => {
  res.status(400).json({
    error: 'Bad Request',
    message: 'Your error message here'
  });
});

// Native HTTP
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(400, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Bad Request',
    message: 'Your error message here'
  }));
}).listen(3000);
When to Use This Code
  • Request is syntactically malformed (invalid JSON, wrong content-type)
  • Required parameters are missing entirely
  • Use 422 instead when syntax is valid but semantically incorrect
  • Generic client error when no more specific 4xx code applies
SEO Handling

Indexing

Pages returning 400 are not indexed. Search engines treat this as a client error and won't include the URL in search results.

Crawler Behavior

Crawlers note the error and may reduce crawl frequency for URLs consistently returning 400. They'll retry occasionally.

Google Notes

Fix 400 errors quickly if they affect important pages. Check Google Search Console for crawl errors to identify affected URLs.

Related Status Codes

400 Bad Request FAQ

What causes a 400 Bad Request error?

Malformed JSON in request body. Missing required fields. Invalid query parameters.

When should I use 400 Bad Request?

Request is syntactically malformed (invalid JSON, wrong content-type). Required parameters are missing entirely. Use 422 instead when syntax is valid but semantically incorrect. Generic client error when no more specific 4xx code applies.