Mail app enable (install) does not start

It should be great if there is anybode who can help me out with this problem when installing/enabling Nextcloud mailapp. Hopefully the information here is enough to understand..:slight_smile:

Thanks in advance, regards, Remko

  • Nextcloud Server version (e.g., 29.x.x):
    • Winter 33.0.8
  • Operating system and version (e.g., Ubuntu 24.04):
    • 24.04
  • Web server and version (e.g, Apache 2.4.25):
    • latest update
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Latest update
  • PHP version (e.g, 8.3):
    • latest update
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes (other instance works well)
  • When did this problem seem to first start?
    • when I tried to add the Nextcloud Mail app
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • AIO (instance serviced by Yourdata Network)
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

When installing the Mailapp by clicking in the apps console on download and enable, I got this error.

An error occured during the request. Unable to proceed. The column “Archive mailbox ID” on table “OC_mail_accounts” already exists.

Steps to replicate it (hint: details matter!)

(I use Brave browser)

  1. First I tried to download and enable the Nextcloud mail app, but that did not work because there were updating problems. So

  2. Second My service provider did help me out updating all AIO containers, normally that goes automatically, now it didn´t and so my service provider did help me out and got everything working again.

  3. Then I tried again download and enable and I got this error message, so I tried a remove on the mailapp and tried again inclusive deleting the cookies in de browser. Did not work.

Nextcloud log

Error
settings
ColumnAlreadyExists
The column "archive_mailbox_id" on table "oc_mail_accounts" already exists.
could not enable apps

Aug 31, 2026, 9:45:28 AM

Error
cron
DbalException
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "nextcloud-aio-database" (172.18.0.7), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?

Aug 31, 2026, 1:01:10 AM

Error
no app in context
Exception
There was a problem finding the task

Aug 31, 2026, 1:01:10 AM

Warning
no app in context
Exception
SQLSTATE[HY000]: General error: 7 server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 31, 2026, 1:01:10 AM

Warning
no app in context
Exception
SQLSTATE[HY000]: General error: 7 server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 31, 2026, 1:01:10 AM

Error
core
Exception
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "nextcloud-aio-database" (172.18.0.7), port 5432 failed: FATAL: the database system is not yet accepting connections DETAIL: Consistent recovery state has not been yet reached.

Aug 30, 2026, 1:18:49 PM

Error
core
Exception
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "nextcloud-aio-database" (172.18.0.7), port 5432 failed: FATAL: the database system is not yet accepting connections DETAIL: Consistent recovery state has not been yet reached.

Aug 30, 2026, 1:18:49 PM

Error
remote
Exception
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "nextcloud-aio-database" (172.18.0.7), port 5432 failed: FATAL: the database system is not yet accepting connections DETAIL: Consistent recovery state has not been yet reached.

Aug 30, 2026, 1:18:49 PM

Fatal
eurooffice
Exception
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "nextcloud-aio-database" (172.18.0.7), port 5432 failed: FATAL: the database system is not yet accepting connections DETAIL: Consistent recovery state has not been yet reached.

Aug 30, 2026, 1:18:49 PM

Error
core
DbalException
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 no connection to the server

Aug 30, 2026, 1:18:46 PM

Error
core
DbalException
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 FATAL: terminating connection due to unexpected postmaster exit server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 30, 2026, 1:18:46 PM

Error
core
DbalException
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 no connection to the server

Aug 30, 2026, 1:18:46 PM

Error
core
DbalException
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 FATAL: terminating connection due to unexpected postmaster exit server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 30, 2026, 1:18:46 PM

Warning
no app in context
Exception
SQLSTATE[HY000]: General error: 7 FATAL: terminating connection due to unexpected postmaster exit server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 30, 2026, 1:18:46 PM

Error
remote
DbalException
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 FATAL: terminating connection due to unexpected postmaster exit server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 30, 2026, 1:18:46 PM

Error
remote
DbalException
An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 FATAL: terminating connection due to unexpected postmaster exit server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Aug 30, 2026, 1:18:46 PM

Tips for increasing the likelihood of a response

Hello

This makes sense once you line up the timeline: your original mail app install attempt got hit by the database going down mid-migration (all those “database system is not yet accepting connections” / “server closed the connection unexpectedly” errors from Aug 30), so the migration that adds archive_mailbox_id to oc_mail_accounts partially ran, the column got created, but Nextcloud’s internal migration tracking never got marked as complete because the connection dropped before it could finish. Now every retry sees “run this migration” as still pending, tries to add the column again, and fails because it’s already there.

This isn’t something to fix via the UI, uninstall/reinstall through the apps page won’t touch the actual DB migration state table. It needs a manual DB fix:

Connect to the AIO database container directly:
docker exec -it nextcloud-aio-database psql -U nextcloud -d nextcloud_database
Check the migrations table for the mail app to see what’s marked as applied vs not:
sql
SELECT * FROM oc_migrations WHERE app = ‘mail’ ORDER BY version;
Compare against the mail app’s actual migration files (in apps/mail/lib/Migration/) to find which version corresponds to adding archive_mailbox_id. Once identified, manually insert that version as applied so Nextcloud stops trying to re-run it:
sql
INSERT INTO oc_migrations (app, version) VALUES (‘mail’, ‘XXXXXXXXXXXX’);

(replace XXXXXXXXXXXX with the actual version string from the migration filename)

Since this touches the database directly and a wrong entry can cause other issues, it’s worth taking a snapshot/backup of the database container’s volume before running the INSERT, and ideally posting the exact migration filenames from the mail app’s Migration folder here first so someone can confirm the right version string before you commit it.

Also worth flagging to your service provider (Yourdata Network) separately, since the DB going down mid-operation during their container update is what caused this in the first place, worth them checking why postgres terminated unexpectedly during that maintenance window so it doesn’t repeat on the next update.

Regards,

Herrick

DevOps Engineer @accuweb.cloud

Herrick, wow, very well explained to me however my tech level to do it myself, doubting on that, but no problem I will first try my service provider to do this for me.

In the end we need a support company to solve this kind of issues.

So very very many thanks, next step and hopefully soon resolved.

And probably this also a problem for the whole Nextcloud environment on my account because at the moment it does qork, but very slow en bad.

kind regards, Remko