4xx Client errors

HTTP 409 Conflict

HTTP 409 Conflict means the request clashes with the current state of the resource, such as a duplicate or a stale update.

What 409 Conflict means

Use 409 when the input is valid but cannot be applied right now: a username that is already taken, or an update based on an old version of the record (optimistic concurrency). The client can usually resolve it and retry.

Common causes

  • A unique index violation, for example MongoDB error code 11000 (duplicate key).
  • A version mismatch when two users edit the same document.
  • A state-machine rule, such as cancelling an order that already shipped.

How to fix or use it

Map duplicate-key errors to 409 with a clear message, and use a version field (Mongoose optimisticConcurrency or __v) to detect lost updates.

Express (Node.js) example

try {
  await User.create(req.body);
} catch (err) {
  if (err.code === 11000) return res.status(409).json({ message: 'Email already registered' });
  throw err;
}

SEO impact

No SEO effect: 409 belongs to API writes, not to crawlable pages.

Other 4xx Client errors codes