Geonode logo
Website and server errors

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.

WhereWhat you see
curl -fcurl: (22) The requested URL returned error: 409
Python urlliburllib.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
axiosAxiosError: 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.

  1. 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
  2. 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.

    1. Look up the name or ID that the error mentions.

    2. If it is what you meant to create, treat the 409 as done.

    3. If it is something else, send your request under a new name.

    4. For uploads, set the API's conflict option; Microsoft Graph takes @microsoft.graph.conflictBehavior=rename or replace.

  3. 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.

    1. Find the header name in the API's docs; Stripe uses Idempotency-Key.

    2. Generate one random UUID per operation, before the first attempt.

    3. Send that same key on every retry of the operation.

    4. 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.

  1. Send If-None-Match: * with a creating PUT, so it never replaces something that appeared meanwhile.

  2. Let one worker or queue own all writes to a record.

  3. Keep automatic retries off for POST; urllib3 and undici's retry handler leave it out by default.

  4. Where the API allows, create with PUT to a URL you choose; repeating a PUT adds nothing.

  5. If you run the API, say in the response body which field or version is in the way.

API replies that show the resultGeonode's IP whitelist API answers each add or removal with the full updated list.
Try residential proxies

Related errors

Learn more

FAQ

It means the server could not complete the request because it conflicts with the resource as it stands now. RFC 9110 keeps this code for conflicts the user might resolve and then resubmit.

Reload the latest version of what you were changing, make your edit again and save. If the message says the item already exists, use that one or choose a different name.

412 Precondition Failed answers a condition header you sent, such as If-Match with an old ETag. 409 needs no such header; GitHub, Kubernetes and CouchDB return it when the version sent with a request is outdated.

Not unchanged: curl --retry leaves 409 off its retryable codes, and Google Cloud Storage tells clients to consider the resource's new state. Wait and resend only when the body says another operation is still running.

A Squid proxy with host_verify_strict on answers 409 when the Host header does not match the destination address; Geonode's gateway documents no 409 of its own. Any layer that resends a POST after a lost reply can also trigger one.

In WebDAV, 409 means a parent folder is missing: under RFC 4918 a PUT or MKCOL fails until every folder higher in the path exists. Create the folders top down, then upload.

See every active sticky session

One GET to Geonode's API lists each session's ID, port and country.