mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-04-25 17:25:57 +03:00
[GH-ISSUE #6611] Crash loop: Referencing column 'user_uuid' and referenced column 'uuid' in foreign key constraint 'sso_users_ibfk_1' are incompatible. #2484
Labels
No labels
SSO
Third party
better for forum
bug
bug
documentation
duplicate
enhancement
future Vault
future Vault
future Vault
good first issue
help wanted
low priority
notes
pull-request
question
troubleshooting
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vaultwarden#2484
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pro-to-co-ls on GitHub (Dec 28, 2025).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/6611
Prerequisites
Vaultwarden Support String
Its crashing
Vaultwarden Build Version
v1.35.0
Deployment method
Official Container Image
Custom deployment method
No response
Reverse Proxy
traefik
Host/Server Operating System
Linux
Operating System Version
Debian
Clients
Web Vault
Client Version
No response
Steps To Reproduce
Upgraded to the latest version and getting:
Expected Result
it should not crash
Actual Result
see error above
Logs
Screenshots or Videos
No response
Additional Context
No response
@stefan0xC commented on GitHub (Dec 28, 2025):
You neither provided a support string nor did you search for existing issues! Otherwise you might have found https://github.com/dani-garcia/vaultwarden/issues/6602#issuecomment-3694436267 or https://github.com/dani-garcia/vaultwarden/discussions/6603
@pro-to-co-ls commented on GitHub (Dec 28, 2025):
@stefan0xC if you notice the error I posted is different from the ones you linked.
Also I can not provide a support string if its crash looping.
(I also don't understand the hostility and why this should not be fixed at the root cause - like ensuring tables are created correctly)
@stefan0xC commented on GitHub (Dec 28, 2025):
Can you still make sure that the collation and charset of your database and tables are correctly set? Or are you not using MySQL or MariaDB?
@williamdes commented on GitHub (Dec 28, 2025):
I have this in my logs
Probably related in some way
@SuperGaleb commented on GitHub (Dec 29, 2025):
Same problem on my installation. This is definitely related to character set being incorrectly set at the start (few years ago).
Reverting to: image: vaultwarden/server:1.34.3 and everything is back online again.
Database changed
MariaDB [vaultwarden]> SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = "vaultwarden";
+----------------------------+------------------------+
| DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+----------------------------+------------------------+
| utf8mb4 | utf8mb4_unicode_ci |
+----------------------------+------------------------+
1 row in set (0.001 sec)
MariaDB [vaultwarden]> SELECT CHARACTER_SET_NAME, COLLATION_NAME FROM information_schema.
COLUMNSWHERE TABLE_SCHEMA = "vaultwarden" AND CHARACTER_SET_NAME IS NOT NULL;+--------------------+-----------------------+
| CHARACTER_SET_NAME | COLLATION_NAME |
+--------------------+-----------------------+
| utf8mb4 | utf8mb4_general_ci |
| utf8mb4 | utf8mb4_general_ci |
| utf8mb4 | utf8mb4_general_ci |
| utf8mb4 | utf8mb4_general_ci |
| utf8mb4 | utf8mb4_general_ci |
However I am not able to change it as per instructions (https://github.com/dani-garcia/vaultwarden/wiki/Using-the-MariaDB-%28MySQL%29-Backend#foreign-key-errors-collation-and-charset).
Setting SET FOREIGN_KEY_CHECKS = 0; and/or SET GLOBAL FOREIGN_KEY_CHECKS=0;
does not work for me.
MariaDB [vaultwarden]> SET foreign_key_checks = 0;
Query OK, 0 rows affected (0.000 sec)
MariaDB [vaultwarden]> ALTER TABLE
users_collectionsCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;ERROR 1832 (HY000): Cannot change column 'user_uuid': used in a foreign key constraint 'users_collections_ibfk_1'
MariaDB [vaultwarden]> ALTER TABLE
foldersCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;ERROR 1833 (HY000): Cannot change column 'uuid': used in a foreign key constraint 'folders_ciphers_ibfk_2' of table 'vaultwarden.folders_ciphers'
MariaDB [vaultwarden]> ALTER TABLE
organization_api_keyCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;ERROR 1832 (HY000): Cannot change column 'org_uuid': used in a foreign key constraint 'organization_api_key_ibfk_1'
MariaDB [vaultwarden]> ALTER TABLE
groupsCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;ERROR 1833 (HY000): Cannot change column 'uuid': used in a foreign key constraint 'collections_groups_ibfk_2' of table 'vaultwarden.collections_groups'
MariaDB [vaultwarden]> ALTER TABLE
sso_nonceCONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;Query OK, 0 rows affected (0.030 sec)
Records: 0 Duplicates: 0 Warnings: 0.....
Only permanent DROP FOREIGN KEY works. Still can not work out how to add back ALTER TABLE child_table ADD CONSTRAINT fk_name FOREIGN KEY (column_name) REFERENCES later.
ALTER TABLE favorites DROP FOREIGN KEY favorites_ibfk_1;
ALTER TABLE favorites DROP FOREIGN KEY favorites_ibfk_2;
.....
@3XC1T3D commented on GitHub (Dec 29, 2025):
i backuped the vaultwarden schema. dopped the schema. modified the collation in the dump file to utf8mb4_unicode_ci and imported the data again. now the error is gone.
@kimpenhaus commented on GitHub (Dec 29, 2025):
@SuperGaleb I had the exactly same - I managed to get it working with this sql:
when all tables were converted I could start the container with no issues.
@SuperGaleb commented on GitHub (Dec 29, 2025):
Unfortunately no luck. This is more/less what I was trying yesterday.
Modifying collation in the dump file to utf8mb4_unicode_ci and importing the data back as 3XC1T3D suggested worked .
Thank you.
MariaDB [vaultwarden]> SET foreign_key_checks = 0;
Query OK, 0 rows affected (0.000 sec)
MariaDB [vaultwarden]>
MariaDB [vaultwarden]> ALTER TABLE
auth_requests-> DROP FOREIGN KEY
auth_requests_ibfk_1,-> DROP FOREIGN KEY
auth_requests_ibfk_2;Query OK, 0 rows affected (0.028 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [vaultwarden]>
MariaDB [vaultwarden]> ALTER TABLE
users-> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ERROR 1833 (HY000): Cannot change column 'uuid': used in a foreign key constraint 'ciphers_ibfk_1' of table 'vaultwarden.ciphers'
MariaDB [vaultwarden]>
MariaDB [vaultwarden]> ALTER TABLE
organizations-> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ERROR 1833 (HY000): Cannot change column 'uuid': used in a foreign key constraint 'ciphers_ibfk_2' of table 'vaultwarden.ciphers'
MariaDB [vaultwarden]>
MariaDB [vaultwarden]> ALTER TABLE
auth_requests-> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 0 rows affected (0.033 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [vaultwarden]>
MariaDB [vaultwarden]> ALTER TABLE
auth_requests-> ADD CONSTRAINT
auth_requests_ibfk_1-> FOREIGN KEY (
user_uuid) REFERENCESusers(uuid),-> ADD CONSTRAINT
auth_requests_ibfk_2-> FOREIGN KEY (
organization_uuid) REFERENCESorganizations(uuid);ERROR 1822 (HY000): Failed to add the foreign key constraint. Missing index for constraint 'auth_requests_ibfk_1' in the referenced table 'users'
MariaDB [vaultwarden]>
MariaDB [vaultwarden]> SET foreign_key_checks = 1;
Query OK, 0 rows affected (0.000 sec)
@SuperGaleb commented on GitHub (Dec 29, 2025):
Worked like a charm. Thank you !!!
@SuperGaleb commented on GitHub (Dec 29, 2025):
For those who still have same problem, this is how I fixed it. Thanks to 3XC1T3D for this idea.
First, generate a SQL dump using mariadb-dump with appropriate flags (change container name and db-passwd to your setup):
Create a copy of the dump file and use sed to replace all instances of existing character set and collation definitions with utf8mb4 and utf8mb4_unicode_ci.
Before importing, ensure the target database is recreated with the correct character set:
Import the modified dump:
docker exec -i <container_name> mariadb -u 'root' -p<your_db-passwd>' vaultwarden < /home/supergaleb/opt/db-dumps/vw.sqlVerify the settings (log into your container/mariadb first):
@DorianCoding commented on GitHub (Dec 30, 2025):
I have the same problem, dumping the database as stated works, as long as the character set by default of the database is also changed accordingly.
@ballerbude commented on GitHub (Dec 30, 2025):
This was a great help. Everything is up and running again. Thank you!
@BlackDex commented on GitHub (Jan 8, 2026):
If tables are created using a wrong schema, encoding or collate, that isn't something we can fix afterwards.
Ill see if we can somehow fix this to be a default during creation and connection, but that still doesn't fix the tables it self, that is something the database admin should do manually.
@sigma2017 commented on GitHub (Jan 13, 2026):
Hello, I was using the latest vaultwarden docker image (5 month old so I suppose I had v1.34.3)
How I fixed it after docker pull vaultwarden/server:latest (All the changes were performed in mariadb. I am using bitnami/mariadb-galera 11.4.7 with wsrep_provider_version | 4.22(r216f068))
Step 1: Diagnostic Schema
→ 26/28 latin1 tables.
Step 2: Script Convert (most of the tables)
The following 3 tables can not be converted, and tried again only for these tables:
Step 3: Fix blocked FK blocked (auth_requests -> users/organizations)
Step 4: Final check:
→ All utf8mb4_unicode_ci
SHOW STATUS LIKE 'wsrep%'; -- cluster_size=3, Synced, ready=ONPas 5: Restart & Test
On both nodes where galera is running:
docker restart bitwardenOn the node where I have nginx RP and arbiter:
docker restart garbdChecking container status:
docker logs bitwarden"Starting Vaultwarden" OK
I use bitwarden (docker container based on the same docker image) for more than 2 years but initially i used single mysql 5.7 node. Since last year I have created a galera cluster and moved the existing database from mysql to mariadb/galera.
Maybe my solution doesn't fit all scenarios, I wanted to mention this details to avoid confusion.
What I have explained here is exactly what I did, no more, no less.