SQLSTATE[HY000] [2002] No route to host in [/var/www/passbolt/vendor/cakephp/cakephp/src/Database/Driver.php, line 92]

Morning,

I will describe my hole installation process and errors. I actually run CentOS 8 this is why some install methods are different, just to avoid some error from CentOS.

DOCKER

Requirements: rng-tools or haveged

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

sudo yum remove podman

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

sudo yum-config-manager --add-repo url (can´t put more than one link on post)

sudo yum install docker-ce docker-ce-cli containerd.io --nobest

sudo systemctl start docker

Test: sudo docker run hello-world


DOCKER COMPOSE INSTALLATION

sudo curl -L “url (can´t put more than one link on post)-(uname -s)-(uname -m)” -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

GIT

sudo yum install git

PASSBOLT

git clone url (can´t put more than one link on post)

cd passbolt_docker

docker-compose -f docker-compose.yml up

docker-compose exec passbolt su -m -c “/var/www/passbolt/bin/cake passbolt register_user -u user@xxx.com -f user -l usersurname -r admin” -s /bin/sh www-data

ERROR

SQLSTATE[HY000] [2002] No route to host in [/var/www/passbolt/vendor/cakephp/cakephp/src/Database/Driver.php, line 92]


NON DOCKER COMPOSE INSTALLATION

docker pull passbolt/passbolt:latest
docker network create passbolt_network
docker volume create mariadb_passbolt_data
docker run -d --name mariadb --net passbolt_network --mount source=mariadb_passbolt_data,target=/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=passboltdb -e MYSQL_USER=user -e MYSQL_PASSWORD=user mariadb

docker run --name passbolt --net passbolt_network -p 443:443 -p 80:80 -e DATASOURCES_DEFAULT_HOST=mariadb -e DATASOURCES_DEFAULT_PASSWORD=root -e DATASOURCES_DEFAULT_USERNAME=root -e DATASOURCES_DEFAULT_DATABASE=passboltdb -e APP_FULL_BASE_URL=https://passbolt.local passbolt/passbolt:latest
or
docker run --name passbolt --net passbolt_network -p 443:443 -p 80:80 -e DATASOURCES_DEFAULT_HOST=mariadb -e DATASOURCES_DEFAULT_PASSWORD=user -e DATASOURCES_DEFAULT_USERNAME=user -e DATASOURCES_DEFAULT_DATABASE=passboltdb -e APP_FULL_BASE_URL=https://passbolt.local passbolt/passbolt:latest

ERROR:

SQLSTATE[HY000] [2002] No route to host

&

SQLSTATE[HY000] [2002] No route to host in [/var/www/passbolt/vendor/cakephp/cakephp/src/Database/Driver.php, line 92]


Looks like same error and i can´t resolve it. I try to disable firewall but the “SQLSTATE[HY000] [2002] No route to host” error persist…

I try to reach the “Driver.php” file but cant acces to the docker bash on the “non compose installation” and in the “compose installation” at lin2 92 i can read jus the var $config and i don´t know where it comes or if the problem comes from another place.

Thanks for your time!

Hi Pablo,

Could you provide the env variables values, specially the database hostname?
Are you able to connect from the passbolt container to the database container?

docker-compose exec passbolt bash
mysql -h db -p

I just use the default envs for testing and… no, can´t connect (error 115), good point! Login in db container works fine.

I will try to resolve this step first, thank,s for the advice but if you have any suggestions… they are welcome!

[root@localhost env]# ls
mysql.env passbolt.env
[root@localhost env]# cat mysql.env
MYSQL_ROOT_PASSWORD=test
MYSQL_DATABASE=passbolt
MYSQL_USER=passbolt
MYSQL_PASSWORD=P4ssb0lt
[root@localhost env]# cat passbolt.env

URL

APP_FULL_BASE_URL=https://passbolt.local

Database settings

DATASOURCES_DEFAULT_HOST=db
DATASOURCES_DEFAULT_USERNAME=passbolt
DATASOURCES_DEFAULT_PASSWORD=P4ssb0lt
DATASOURCES_DEFAULT_DATABASE=passbolt
DATASOURCES_DEFAULT_PORT=3306

Registration

PASSBOLT_REGISTRATION_PUBLIC=true

Have you made any progress?

Nope, not yet. I´m trying to put a “restart: always” on the compose.yml, check if the ports are opened and change to the bridge default connection… try to open ipv4 forwarding, enable forwarding but same error by the way.
I can login inside of the mariadb container but not from the other one (115 error) look like a obvious connection problem.
Someone told me try to prune volumes so… that will be my next step…
Any ideas?
Thanks!

Morning guys,

I found this related issue but not working at all: Docker Compose installation

I try to prune volumens in every change:

docker-compose down
docker-compose rm
docker volume prune
docker images | grep mariadb | awk ‘{print $3}’ | xargs docker rmi
docker images | grep passbolt | awk ‘{print $3}’ | xargs docker rmi

I made some test addding “restart: always” and it makes it but nothing else change. Throws this two errors:

Exception: SQLSTATE[HY000] [2002] No route to host in [/var/www/passbolt/vendor/cakephp/cakephp/src/Database/Driver.php, line 92]

Exception: There was a problem connecting to the database: SQLSTATE[HY000] [2002] No route to host in [/var/www/passbolt/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php, line 127]

I try to made some changues on the docker-compose.yml deleting “command” line or adding others that i found in the other post:

command:
  - /bin/bash
  - -c
  - |
    sleep 30
    /docker-entrypoint.sh

or

command: ["/docker-entrypoint.sh"]

But not sure if when you say in the other post “Could you try overriding the command on docker-compose.sh” if you refer to a different file and not the “docker-compose.yml”

Thanks for your time!

Hi @pablo,

Please check if the connectivity is working between both containers like:

docker-compose up -d (passbolt container will crash)
docker-compose run passbolt bash
mysql -u root -h db -p

Hi Diego, this is what happened:

[root@localhost passbolt_docker]# docker-compose up -d
Starting passbolt_docker_db_1 … done Starting passbolt_docker_passbolt_1 … done [root@localhost passbolt_docker]# docker-compose run passbolt bash
Starting passbolt_docker_db_1 … done root@122cffab1287:/var/www/passbolt# mysql -u root -h db -p
Enter password:
ERROR 2002 (HY000): Can’t connect to MySQL server on ‘db’ (115)
root@122cffab1287:/var/www/passbolt#

I see looks like it can’t resolve the database

Could you paste your docker-compose.yml ?

Looks to me too but i can´t resolve it yet.

The passbolt “command” line you see was the last test that i tell you about it before.

The db container is available, right? I have seen some users reporting slow times on the database availability making crash passbolt container at start. This issue was fixed a few months back but mayber there is a regression…

Could you post the full docker-compose up log?

Hi again,

I tried to reproduce on a centos VM running docker. I installed docker slightly different from you. I followed the official install instructions then installed composer like this

Finally:

git clone https://github.com/passbolt/passbolt_docker
cd passbolt_docker
docker-compose up

And it worked fine. Could it be something related with your docker install?

Correction on my side I installed it on centos7 I realized that you are using centos8 too much diagonal reading :sweat_smile:

Still it works for me in centos8 I can’t reproduce your issue :S

Steps:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum-config-manager --enable docker-ce-test
dnf install docker-ce --nobest -y
systemctl start docker

Install composer as mentioned in previous post, cloned passbolt_docker repo and run it with no issues.

Still does´t work… but i will try again in my personal laptop.

My last test comands based on your suggestions:

Thank´s for all your advices!

There is no firewall or any other software preventing the containers to communicate, right?

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.