# Stalwart suddenly stopped connecting to mySQL

**URL:** https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948
**Category:** Questions
**Created:** [October 15, 2026, 9:27pm UTC](https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948 "2026-10-15T21:27:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![neothomas](https://support.stalw.art/letter_avatar_proxy/v4/letter/n/eb9ed0/32.png) [@neothomas](https://support.stalw.art/u/neothomas)
#### Post date: [October 15, 2026, 9:27pm UTC](https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948/1 "2026-10-15T21:27:08Z")

</div>

### Your question

Hello there.

I have had my Stalwart stack (stalwart container + mySQL container) running in docker since June with no problems.

Everything was fine until 2 or 3 weeks or so ago. I realized I couldn’t access my instance’s web page, and so, when checking the logs, I realized there were a few logs saying a connection to the database couldn’t be established.

At the time I was using the image stalwartlabs/stalwart:v0.16, and I updated my instance to use stalwartlabs/stalwart:latest.

Right now, when I spin up my stalwart container there are the only two lines I get:

`⚠️ Startup failed: Failed to create tables: MySQL error (store.mysql-error): reason = Input/output error: Input/output error: Connection refused (os error 111)`  
`⚠️ Startup failed: Failed to create tables: MySQL error (store.mysql-error): reason = Input/output error: Input/output error: Connection refused (os error 111)`

I already checked several things like docker networking and other basic troubleshooting.

Eventually I fixed the webpage’s problem by restarting the host machine, but after a day or so, I’m getting 502 Bad Gateway again, and the SQL problem persists.

The weird thing (or not), is that I can still receive and send emails just fine.

### I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

---

<div class="post-metadata">

### Author: ![stalwart](https://support.stalw.art/user_avatar/support.stalw.art/stalwart/32/12_2.png) [@stalwart](https://support.stalw.art/u/stalwart)
#### Post date: [October 18, 2026, 5:17pm UTC](https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948/2 "2026-10-18T17:17:05Z")

</div>

Connection refused means the MySQL host resolved but nothing was listening on that port as seen from inside the Stalwart container. Stalwart can’t start without its data store, so it exits at startup, and the 502 is your proxy finding nothing behind it.

I’d start with `docker ps -a` and the MySQL container’s logs: a crash loop, a full disk or a long InnoDB recovery after an unclean shutdown all look like this from Stalwart’s side. If MySQL is up, check the data store `host` in `/etc/stalwart/config.json`. It should be the compose service name; a container IP changes when the container is recreated, which would also explain a reboot fixing it for a day. A healthcheck on MySQL plus `depends_on: condition: service_healthy` on Stalwart keeps it from starting before the database is ready ([MySQL backend](https://stalw.art/docs/storage/backends/mysql)).

Mail can’t be going through a container that fails at startup, so what’s handling it? An old container from the `v0.16` image still running would fit. Also, pin `v0.16` again: `latest` will move to 1.0 when it’s released at the end of the month.

---

<div class="post-metadata">

### Author: ![neothomas](https://support.stalw.art/letter_avatar_proxy/v4/letter/n/eb9ed0/32.png) [@neothomas](https://support.stalw.art/u/neothomas)
#### Post date: [November 6, 2026, 11:09am UTC](https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948/3 "2026-11-06T11:09:48Z")

</div>

Hello there.

First of all, I’m sorry for the delay in my response.

Strangely enough, even though I get these errors, the Stalwart app IS working, at least to some extent.

I get 502 when I try to access the web admin page through my public record, but the page is still accessible through my internal IP, via a VPN.

After doing docker ps -a I can confirm I have only one container running the Stalwart image.

MySQL server logs look fine:

> 2026-10-17T23:30:48.902641Z 0 [System] [MY-015015] [Server] MySQL Server - start.
> 
> 2026-10-17T23:30:50.913369Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 9.6.0) starting as process 1
> 
> 2026-10-17T23:30:50.915949Z 0 [System] [MY-015590] [Server] MySQL Server has access to 4 logical CPUs.
> 
> 2026-10-17T23:30:50.916060Z 0 [System] [MY-015590] [Server] MySQL Server has access to 16781709312 bytes of physical memory.
> 
> 2026-10-17T23:30:51.091293Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
> 
> 2026-10-17T23:30:54.131447Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
> 
> 2026-10-17T23:30:57.479321Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
> 
> 2026-10-17T23:30:57.479381Z 0 [System] [MY-013602] [Server] Channel mysql\_main configured to support TLS. Encrypted connections are now supported for this channel.
> 
> 2026-10-17T23:30:57.496460Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location ‘/var/run/mysqld’ in the path is accessible to all OS users. Consider choosing a different directory.
> 
> 2026-10-17T23:30:57.727117Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: ‘::’ port: 33060, socket: /var/run/mysqld/mysqlx.sock
> 
> 2026-10-17T23:30:57.727595Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: ‘9.6.0’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server - GPL.

Also, regarding the 502. After I restarted my VPS, it worked fine for a bit even through the public address. Only after a few hours did it go back to giving me the 502.

Furthermore, as I mentioned before, I’m still able to send and receive emails through my public address.

I really don’t know what is happening, it seems my Stalwart instance is somewhat zombified. I would greatly appreciate any help.

---

<div class="post-metadata">

### Author: ![neothomas](https://support.stalw.art/letter_avatar_proxy/v4/letter/n/eb9ed0/32.png) [@neothomas](https://support.stalw.art/u/neothomas)
#### Post date: [November 6, 2026, 11:15am UTC](https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948/4 "2026-11-06T11:15:58Z")

</div>

Just to add:

I just repinned v0.16 as you suggested which prompted a container restart.

The logs for the container are completely empty after the restart but the instance is still working (via VPN, public access is still giving 502).

Emails are still working as I just tested sending and receiving emails from a Gmail address.

---

<div class="post-metadata">

### Author: ![stalwart](https://support.stalw.art/user_avatar/support.stalw.art/stalwart/32/12_2.png) [@stalwart](https://support.stalw.art/u/stalwart)
#### Post date: [November 8, 2026, 2:16pm UTC](https://support.stalw.art/t/stalwart-suddenly-stopped-connecting-to-mysql/1948/5 "2026-11-08T14:16:01Z")

</div>

From what you describe, Stalwart itself is fine now. It answers over the VPN and mail goes in and out, so it’s running and connected to MySQL. Those `Connection refused` lines were most likely from a start where the Stalwart container came up before MySQL was ready, and the healthcheck with `depends_on` from my earlier post prevents that.

That leaves the path from the public side to the admin page. Mail reaches Stalwart directly on its own ports, but the web page goes through your reverse proxy, and a 502 is the proxy saying it couldn’t get a valid answer from the upstream. Working for a few hours after a reboot and then failing usually means the proxy has an upstream address that goes stale, for example a container IP it resolved once at startup, or a connection pool to the backend that breaks and never recovers.

Which reverse proxy are you using, and what does its error log say at the moment it returns a 502? That line normally names the upstream address and the reason (refused, timed out, reset), which will tell us which side to look at.
