How to Fix an HTTP 409 Conflict Error
Tell a stale copy from a duplicate or a repeated request, with fetch-and-resend code for cURL, Python and Node.js.
Updated
TL;DR
A 409 Conflict comes from the website or API: your request clashes with what the server holds now, such as a newer saved version or an existing name. Fetch the current version, reapply your change and resend.
How clients and services word a 409
What five clients print, then the conflict text Kubernetes puts in the response body.
| Where | What you see |
|---|---|
| curl -f | curl: (22) The requested URL returned error: 409 |
| Python urllib | urllib.error.HTTPError: HTTP Error 409: Conflict |
| Python requests, raise_for_status() | requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://shop.example/api/items/1 |
| Node.js fetch() (res.status, res.statusText) | 409 Conflict |
| axios | AxiosError: Request failed with status code 409 |
| Kubernetes API (message in the 409 body) | Operation cannot be fulfilled on pods "web-1": the object has been modified; please apply your changes to the latest version and try again |
Why this happens
Your request was built on data that has changed since you last looked.
Most often someone else saved the same record after you loaded it, or the thing you are creating already exists. The identical request sent again meets the same stored state and gets the same answer.
Diagnose your 409 first
Start in the browser; the last two checks need a terminal or client logs.
Read the text that came with the 409; if it says a name, email or ID already exists, you tried to create a duplicate.
Open the same record in a second tab; if it shows edits you did not make, someone saved after you loaded your copy.
Look for Cloudflare's Error 1001 on the page; if present, Cloudflare sent the 409 for a DNS resolution error, not a data clash.
Compare the version you sent, such as an ETag, _rev or resourceVersion, with a fresh GET; if they differ, your copy was stale.
Search your client's log just before the 409; if the same POST timed out or lost its connection, the first attempt probably went through.
Solutions ranked by effectiveness
Pick the card that matches the cause; none of them is a plain retry.
- Most common fix
Fetch the current version, then resend
Applies when your copy went stale before you saved. The code reads the item and its ETag, reapplies your change and sends it back with If-Match; rerun the single-pass cURL tab after a 409.
import json, urllib.error, urllib.request url = "https://example.com/api/items/1" for attempt in range(3): with urllib.request.urlopen(url, timeout=15) as res: etag, item = res.headers["ETag"], json.load(res) item["stock"] -= 1 # reapply your change to the fresh copy head = {"If-Match": etag, "Content-Type": "application/json"} req = urllib.request.Request(url, json.dumps(item).encode(), head, method="PUT") try: print(urllib.request.urlopen(req, timeout=15).status); break except urllib.error.HTTPError as err: if err.code not in (409, 412) or attempt == 2: raise - Check next
Use what exists or rename yours
Applies when what you tried to add is already on the server. It may be exactly what you wanted.
Look up the name or ID that the error mentions.
If it is what you meant to create, treat the 409 as done.
If it is something else, send your request under a new name.
For uploads, set the API's conflict option; Microsoft Graph takes @microsoft.graph.conflictBehavior=rename or replace.
- For developers
Send an idempotency key with writes
Applies when a timeout or dropped connection made your client resend a POST that had already worked. Where the API documents a key, it recognizes the repeat and returns the first result.
Find the header name in the API's docs; Stripe uses Idempotency-Key.
Generate one random UUID per operation, before the first attempt.
Send that same key on every retry of the operation.
Where the API has no key, look the record up before resending a POST.
Stop the 409 from coming back
Habits for clients and API owners that make conflicts rarer and easier to resolve.
Send If-None-Match: * with a creating PUT, so it never replaces something that appeared meanwhile.
Let one worker or queue own all writes to a record.
Keep automatic retries off for POST; urllib3 and undici's retry handler leave it out by default.
Where the API allows, create with PUT to a URL you choose; repeating a PUT adds nothing.
If you run the API, say in the response body which field or version is in the way.
Related errors
Learn more
FAQ
See every active sticky session
One GET to Geonode's API lists each session's ID, port and country.


