postal initialize' fails with "Can't connect to local MySQL server through socket" on Ubuntu 24.04 #3455
Unanswered
ayoub21dev
asked this question in
Help with using Postal
Replies: 1 comment
-
Its trying to use the socket and not the port so what have you set as the hostname for the connections in the config file? Don't forget there are two copies |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to set up a fresh installation of Postal on a clean Ubuntu 24.04.3 LTS server. I have followed the official documentation carefully, but I'm consistently running into an issue where the CLI tools (initialize and make-user) fail to connect to the database.
The Issue:
All services (mariadb, rabbitmq, web, worker, runner) start successfully using docker-compose up -d and are in an Up state.
However, when I try to initialize the database using the runner container, it fails with the following error:
code
Code
docker-compose exec runner postal initialize
...
Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2) (ActiveRecord::ConnectionNotEstablished)
Couldn't create 'postal' database. Please check your configuration.
...
It seems that the postal initialize command is completely ignoring the database configuration provided in /opt/postal/config/postal.yml and is trying to connect to a local socket instead of the mariadb container on the Docker network.
What I have tried:
Using postal.yml: I have configured the main_database and message_database sections to point to the mariadb host. The command still fails with the same socket error.
Using Environment Variables: I removed postal.yml and configured the database connection using environment variables directly in the docker-compose.yml file. The services run, but postal initialize still fails with the same socket error.
Forcing Environment Variables with exec: I even tried forcing the environment variables directly on the exec command (docker-compose exec -e ...), but it still results in the same socket connection error.
It appears there might be a compatibility issue or a bug in how the CLI tools parse the configuration on this specific environment (Ubuntu 24.04 / Docker version).
Here is the docker-compose.yml file I am using, which successfully runs all containers:
code
Yaml
version: '3.8'
services:
mariadb:
image: mariadb
container_name: postal-mariadb
restart: unless-stopped
volumes:
- /opt/postal/mariadb-data:/var/lib/mysql
environment:
- MARIADB_DATABASE=postal
- MARIADB_ROOT_PASSWORD=YourPassword
networks:
- postal-net
rabbitmq:
image: rabbitmq:3.8
container_name: postal-rabbitmq
restart: unless-stopped
volumes:
- /opt/postal/rabbitmq-data:/var/lib/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=YourPassword
- RABBITMQ_DEFAULT_VHOST=postal
networks:
- postal-net
web:
image: ghcr.io/postalserver/postal:3.3.4
container_name: postal-web
restart: unless-stopped
volumes:
- /opt/postal/config:/config
networks:
- postal-net
depends_on:
- mariadb
- rabbitmq
command: postal web-server
worker:
image: ghcr.io/postalserver/postal:3.3.4
container_name: postal-worker
restart: unless-stopped
volumes:
- /opt/postal/config:/config
networks:
- postal-net
depends_on:
- mariadb
- rabbitmq
command: postal worker
runner:
image: ghcr.io/postalserver/postal:3.3.4
container_name: postal-runner
command: sleep 1d
volumes:
- /opt/postal/config:/config
networks:
- postal-net
depends_on:
- mariadb
- rabbitmq
networks:
postal-net:
driver: bridge
Any help or guidance would be greatly appreciated. Thank you
Beta Was this translation helpful? Give feedback.
All reactions