The Basics
- Nextcloud Server version (e.g., 29.x.x):
31.0.6
- Operating system and version (e.g., Ubuntu 24.04):
CloudLinux 1.3
- Web server and version (e.g, Apache 2.4.25):
LiteSpeed, unknown version
- Reverse proxy and version _(e.g. nginx 1.27.2)
n/a
- PHP version (e.g, 8.3):
8.3.22
- Is this the first time you’ve seen this error? (Yes / No):
yes
- When did this problem seem to first start?
2025-06-26T01:55:03+00:00
- Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
Bare Metal
- Are you using CloudfIare, mod_security, or similar? (Yes / No)
No
Summary of the issue you are facing:
Nextcloud Mail stopped working for 3 out of 4 users. According to the logs, 4 out of 6 mail accounts seem to be affected.
Steps to replicate it (hint: details matter!):
The first time this error occured was triggered by a cron job in the middle of the night. I have definitely not touched anything within 6 hours before, and previous cron jobs ran fine. Additionally, 4 mail accounts from 3 different users started being affected at the same time. 2 of these users barely use Nextcloud Mail at all.
Log entries
Nextcloud
Example (the same message appears also for 3 other account_id/name_hash combinations, repeated about every 20 minutes):
DbalException
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5-e5ecf6489ff48b8032{redacted}' for key 'mail_mb_account_id_name_hash'
Trace
/home/{redacted}/lib/private/DB/ConnectionAdapter.php
Line 69
OC\DB\Exceptions\DbalException::wrap()
/home/{redacted}/lib/private/DB/QueryBuilder/QueryBuilder.php
Line 306
OC\DB\ConnectionAdapter->executeStatement()
/home/{redacted}/lib/public/AppFramework/Db/QBMapper.php
Line 116
OC\DB\QueryBuilder\QueryBuilder->executeStatement()
/home/{redacted}/apps/mail/lib/IMAP/MailboxSync.php
Line 244
OCP\AppFramework\Db\QBMapper->insert()
/home/{redacted}/apps/mail/lib/IMAP/MailboxSync.php
Line 185
OCA\Mail\IMAP\MailboxSync->createMailboxFromFolder(
"*** sensitive parameters replaced ***"
)
/home/{redacted}/apps/mail/lib/IMAP/MailboxSync.php
Line 127
OCA\Mail\IMAP\MailboxSync->persist()
/home/{redacted}/lib/public/AppFramework/Db/TTransactional.php
Line 45
OCA\Mail\IMAP\MailboxSync->OCA\Mail\IMAP\{closure}(
"*** sensitive parameters replaced ***"
)
/home/{redacted}/apps/mail/lib/IMAP/MailboxSync.php
Line 118
OCA\Mail\IMAP\MailboxSync->atomic()
/home/{redacted}/apps/mail/lib/BackgroundJob/SyncJob.php
Line 92
OCA\Mail\IMAP\MailboxSync->sync(
"*** sensitive parameters replaced ***"
)
/home/{redacted}/lib/public/BackgroundJob/Job.php
Line 61
OCA\Mail\BackgroundJob\SyncJob->run()
/home/{redacted}/lib/public/BackgroundJob/TimedJob.php
Line 97
OCP\BackgroundJob\Job->start()
/home/{redacted}/lib/public/BackgroundJob/TimedJob.php
Line 84
OCP\BackgroundJob\TimedJob->start()
/home/{redacted}/cron.php
Line 170
OCP\BackgroundJob\TimedJob->execute()
Web Browser
n/a
Web server / Reverse Proxy
n/a
Configuration
Nextcloud
The output of occ config:list system
or similar is best, but, if not possible, the contents of your config.php
file from /path/to/nextcloud
is fine (make sure to remove any identifiable information!):
occ config:list system
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"***REMOVED SENSITIVE VALUE***"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "31.0.6.2",
"overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
"default_language": "de",
"default_locale": "de_DE",
"default_phone_region": "DE",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"htaccess.RewriteBase": "\/",
"installed": true,
"mysql.utf8mb4": true,
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_smtpmode": "smtp",
"mail_sendmailmode": "smtp",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtpauth": 1,
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": "465",
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"maintenance": false,
"maintenance_window_start": 1,
"memcache.local": "\\OC\\Memcache\\APCu",
"twofactor_enforced": "true",
"twofactor_enforced_groups": [
"admin"
],
"twofactor_enforced_excluded_groups": [],
"oidc_login_provider_url": "***REMOVED SENSITIVE VALUE***",
"oidc_login_client_id": "***REMOVED SENSITIVE VALUE***",
"oidc_login_client_secret": "***REMOVED SENSITIVE VALUE***",
"oidc_login_auto_redirect": false,
"oidc_login_button_text": "Log in with Authelia",
"oidc_login_hide_password_form": false,
"oidc_login_use_id_token": true,
"oidc_login_attributes": {
"id": "preferred_username",
"name": "name",
"mail": "email"
},
"oidc_login_default_group": "oidc",
"oidc_login_scope": "openid profile email",
"oidc_login_code_challenge_method": "S256",
"theme": "",
"loglevel": 2
}
}
Apps
The output of occ app:list
(if possible).
occ app:list
Enabled:
- activity: 4.0.0
- app_api: 5.0.2
- bruteforcesettings: 4.0.0
- calendar: 5.3.3
- circles: 31.0.0
- cloud_federation_api: 1.14.0
- comments: 1.21.0
- contacts: 7.1.3
- cospend: 3.0.11
- dav: 1.33.0
- deck: 1.15.1
- federatedfilesharing: 1.21.0
- federation: 1.21.0
- files: 2.3.1
- files_downloadlimit: 4.0.0
- files_pdfviewer: 4.0.0
- files_reminders: 1.4.0
- files_retention: 2.0.1
- files_sharing: 1.23.1
- files_trashbin: 1.21.0
- files_versions: 1.24.0
- firstrunwizard: 4.0.0
- logreader: 4.0.0
- lookup_server_connector: 1.19.0
- mail: 5.1.4
- nextcloud_announcements: 3.0.0
- notes: 4.12.1
- notifications: 4.0.0
- oauth2: 1.19.1
- oidc_login: 3.2.2
- password_policy: 3.0.0
- privacy: 3.0.0
- profile: 1.0.0
- provisioning_api: 1.21.0
- recommendations: 4.0.0
- registration: 2.7.0
- related_resources: 2.0.0
- serverinfo: 3.0.0
- settings: 1.14.0
- sharebymail: 1.21.0
- support: 3.0.0
- survey_client: 3.0.0
- systemtags: 1.21.1
- text: 5.0.0
- theming: 2.6.1
- twofactor_backupcodes: 1.20.0
- twofactor_totp: 13.0.0-dev.0
- updatenotification: 1.21.0
- user_status: 1.11.0
- viewer: 4.0.0
- weather_status: 1.11.0
- webhook_listeners: 1.2.0
- workflowengine: 2.13.0
Disabled:
- admin_audit: 1.21.0
- contactsinteraction: 1.12.0 (installed 1.11.0)
- dashboard: 7.11.0 (installed 7.10.0)
- encryption: 2.19.0
- files_external: 1.23.0
- photos: 4.0.0-dev.1 (installed 3.0.2)
- suspicious_login: 9.0.1
- twofactor_nextcloud_notification: 5.0.0
- user_ldap: 1.22.0