An Evolution API install that loses its sessions at every restart is an install with no persistent volume. The database keeps the instances and messages; Redis, which many guides add, is support; and Docker volumes make sure none of it vanishes when the container is recreated. This article shows how the pieces fit and how to prove that sessions survive.
What each piece does
| Piece |
What it is for |
If it is missing |
| Evolution API |
Receives the requests and talks to WhatsApp. |
Nothing works. |
| PostgreSQL or MySQL |
Keeps the instances and data, according to the project’s documentation. |
The API will not start, or starts with no memory of what existed. |
| Redis |
Many guides use it as support. The documentation says what your version requires. |
Depending on the setup, the service complains or runs with less support. |
| Docker volumes |
Keep on disk what must not disappear. |
Every restart wipes the sessions and makes you scan the QR codes again. |
Both databases are supported. PostgreSQL is the one most guides show, but MySQL or MariaDB are fine if that is what you already know. If you are unsure, see PostgreSQL or MySQL: which one for your project.
Building it to survive
| 1 |
Put the database in a compose service with a named volume for its data. The volume is what remains when the container disappears. For the layout, see Docker Compose with a database.
|
|
| 2 |
Give the API’s instances a volume too, as the project’s example file shows.
|
|
| 3 |
Make the services talk by name. On the same Compose network, the database address is the service name, not localhost. The user and password must match on both sides.
|
|
| 4 |
Do not publish the database or Redis ports. Only the API needs to reach them, inside the Docker network.
|
|
| 5 |
Set the restart policy so the services come back by themselves after a server reboot. Compose has an option for it, and the project’s example usually includes it.
|
|
Proving it works
| 1 |
Link a test instance and confirm it sends.
|
|
| 2 |
Restart the services with docker compose restart. The instance should come back linked, with no QR.
|
|
| 3 |
Stop and recreate: docker compose down then docker compose up -d. This deletes the containers but not the volumes. The instance is still there.
|
|
| 4 |
Reboot the VPS itself once, at a quiet moment, and see whether everything comes back on its own.
|
|
A volume is not a backup. It protects against a restart, not against a failing disk, a container removed by mistake or a docker compose down -v. Take database dumps (see backups with mysqldump and pg_dump) and keep them off the server.
|
|
Need more disk for the database? Have a look at the VPS plans.
See VPS servers
|
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon) See plans |