HTTP 409 Conflict indicates that the request could not be completed because it conflicts with the current state of the resource on the server.
A 409 response is typically returned when the server detects that applying the request would violate a constraint, such as updating stale data or creating a duplicate record.
// Express.js example returning HTTP 409 Conflict
res.status(409).json({
message: "Conflict: Resource already exists"
});
The server responds with status code 409 and a message explaining the conflict so the client can resolve it.
// Simulated client-side conflict check
function createUser(username) {
if (username === "admin") {
console.log("409 Conflict: Username already taken");
}
}
createUser("admin");
Try to register a new user. Existing users: admin, root.