Duplicate key value violates unique constraint

Hi everyone, some times we are getting this error when we try to save

There was a problem saving the workflow: "duplicate key value violates unique constraint “pk_eded7d72664448da7745d551207"”

the workaround, copy on notepac the unsafe change, reload the page, paste the code and save.

that’s a postgres constraint error - usually means n8n is trying to insert a workflow version with an id that already exists in the database.

couple things to try:

1. check if you have multiple n8n instances running that might be writing to the same db

2. restart your n8n instance and postgres - sometimes the sequence gets out of sync

3. if youre on self-hosted, check your postgres logs around the time it happens to see the exact constraint

does this happen with a specific workflow or random ones? and are you running latest n8n version?