Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jonjiepb's avatar

How to connect mariadb with docker in sequel ace

Currently working with wordpress with mariadb in docker. I can connect the wordpress to the database but when I try to connect it using sequel ace, it returns an error saying that my credential is not correct.

docker-compose.yml

services:
  maria:
    image: mariadb:latest
    environment:
      MYSQL_DATABASE: wp_maria
      MYSQL_USER: maria
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret

Error - Sequel Ace

Unable to connect to host maria, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Unknown MySQL server host 'maria' (0)
0 likes
9 replies
tisuchi's avatar

@jonjiepb Have you mapped the port of maria DB properly? Because you are accessing docker service from outside of the docker.

Unfortunately, I cannot see any mapping port in your docker-compose.yml file.

jonjiepb's avatar

@tisuchi I also tried to add port for mariadb like so:

services:
  maria:
    image: mariadb:latest
    environment:
      MYSQL_DATABASE: wp_maria
      MYSQL_USER: maria
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret
    ports:
     - 3306:3306

but I still get the same result

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@jonjiepb You need to connect to localhost/127.0.0.1 inside of sequel ace. Also remember to rebuild with docker

jonjiepb's avatar

@Sinnbeck Wow! 127.0.0.1 works. But why? I mean, it should be the name of my container right? Im a bit confused now. uhm

Sinnbeck's avatar

@jonjiepb No. The name of the container is used inside of the containers, to allow the containers to communicate. Sequel ace is outside, and has no knowledge of the containers. Therefor you are connecting to your local machine. Docker has then exposed the port (3306:3306) on localhost to allow the connection. You can therefor also have several datbases in seperate projects which have different ports exposed (for instance 3307:3306). The second number is the port inside the container, and the first is what port you want to listen to on localhost

jonjiepb's avatar

@Sinnbeck Okay I got it now. So basically, I can only use the container name inside my application (e.g. ENV file in laravel) and to be able to use it outside (e.g. sequel ace), I have to expose the port?

siangboon's avatar

you can run the docker ps command to check the running container and the mapping port is showing at the end

Please or to participate in this conversation.