# Postgresql: duplicate key value violates unique constraint "oc\_filecache\_extended\_pkey"

**URL:** <https://help.nextcloud.com/t/postgresql-duplicate-key-value-violates-unique-constraint-oc-filecache-extended-pkey/250216>\
**Category:** ℹ️ Support\
**Tags:** postgresql\
**Created:** [September 27, 2026, 8:49pm UTC](https://help.nextcloud.com/t/postgresql-duplicate-key-value-violates-unique-constraint-oc-filecache-extended-pkey/250216 "2026-09-27T20:49:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccurley](https://help.nextcloud.com/letter_avatar/ccurley/32/5_5575768a8748004e209b776fc1b2916d.png) [@ccurley](https://help.nextcloud.com/u/ccurley)\
**Post date:** [September 27, 2026, 8:49pm UTC](https://help.nextcloud.com/t/postgresql-duplicate-key-value-violates-unique-constraint-oc-filecache-extended-pkey/250216/1 "2026-09-27T20:49:53Z")

</div>

### Which general topic do you have

postgresql generates the message ‘duplicate key value violates unique constraint “oc\_filecache\_extended\_pkey”’ multiple times a day. Log entries look like,

```auto
2026-09-27 00:30:43.380 MDT [1989941] nextcloud@nextcloud ERROR: duplicate key value violates unique constraint "oc_filecache_extended_pkey"
2026-09-27 00:30:43.380 MDT [1989941] nextcloud@nextcloud DETAIL: Key (fileid)=(821) already exists.
2026-09-27 00:30:43.380 MDT [1989941] nextcloud@nextcloud STATEMENT: INSERT INTO "oc_filecache_extended" ("fileid", "creation_time") VALUES($1, $2)
2026-09-27 00:30:43.415 MDT [1989941] nextcloud@nextcloud ERROR: duplicate key value violates unique constraint "oc_filecache_extended_pkey"
2026-09-27 00:30:43.415 MDT [1989941] nextcloud@nextcloud DETAIL: Key (fileid)=(822) already exists.
2026-09-27 00:30:43.415 MDT [1989941] nextcloud@nextcloud STATEMENT: INSERT INTO "oc_filecache_extended" ("fileid", "creation_time") VALUES($1, $2)

```

This is similar to [Database errors in postgresql log (duplicate key value)](https://help.nextcloud.com/latest?max_posts=1&order=activity&status=open), which is now closed.

There are a [number of bugs](https://github.com/nextcloud/server/issues?q=is%3Aissue+is%3Aopen+duplicate+key+value+violates+unique+constraint) on this sort of issue already open.

```auto
root@hawk:~# pre postgres ; nextcloud --version
postgresql	17+278 all
postgresql-17	17.11-0+deb13u1 amd64
postgresql-client	17+278 all
postgresql-client-17	17.11-0+deb13u1 amd64
postgresql-client-common	278 all
postgresql-common	278 all
postgresql-common-dev	278 all
Nextcloud version 3.16.7-1~deb13u1 (Debian built)
Git revision 5584b240f9299c236ba99206b53577460fc12516
Using Qt 6.8.2, built against Qt 6.8.2
Using Qt platform plugin 'xcb'
Using 'OpenSSL 3.5.7 9 Jun 2026'
Running on Debian GNU/Linux 13 (trixie), x86_64
root@hawk:~# 

```

---

<div class="post-metadata">

**Author:** ![ccurley](https://help.nextcloud.com/letter_avatar/ccurley/32/5_5575768a8748004e209b776fc1b2916d.png) [@ccurley](https://help.nextcloud.com/u/ccurley)\
**Post date:** [September 27, 2026, 8:55pm UTC](https://help.nextcloud.com/t/postgresql-duplicate-key-value-violates-unique-constraint-oc-filecache-extended-pkey/250216/2 "2026-09-27T20:55:28Z")

</div>

I get this for other constraints as well. `previews_file_uniq_idx`, `mimetype_id_index`, and `notes_meta_file_user_index`.

```auto
root@hawk:/var/log/postgresql# zgrep 'duplicate key value violates unique constraint' postgresql-17-main.log* | grep -v oc_filecache_extended_pkey
…

```
