There was a problem connecting to the database

Hi, I’m trying run Passbolt on Docker with an RDS database, but I keep getting this error:

Running baseline checks, please wait…
Exception: SQLSTATE[HY000] [2002] No such file or directory 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 such file or directory in [/var/www/passbolt/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php, line 82]

I am building an image with docker compose, like this:

version: “3.4”
services:
passbolt:
build:
context: ./
dockerfile: ./docker/Dockerfile
image:
tty: true
env_file:
- env/passbolt.env
volumes:
- gpg_volume:/var/www/passbolt/config/gpg
- images_volume:/var/www/passbolt/webroot/img/public
tmpfs:
- /run
command:
[
“/docker-entrypoint.sh”,
]
ports:
- 80:80
- 443:443

volumes:
gpg_volume:
images_volume:

My env/passbolt.env is something like this:

DATASOURCES_DEFAULT_HOST=SERVER.REGION.rds.amazonaws.com
DATASOURCES_DEFAULT_USERNAME=USER
DATASOURCES_DEFAULT_PASSWORD=PASSWORD
DATASOURCES_DEFAULT_DATABASE=DATABASE
DATASOURCES_DEFAULT_PORT=3306

Can someone help me, please?

Checklist
[x] I have read intro post: About the Installation Issues category
[x] I have read the tutorials, help and searched for similar issues
[x] I provide relevant information about my server (component names and versions, etc.)
[x] I provide a copy of my logs and healthcheck
[x] I describe the steps I have taken to trouble shoot the problem
[x] I describe the steps on how to reproduce the issue

Hi @Elias Welcome to the forum!

Can you confirm if you already created the database on RDS and have granted privileges on it to the USER? Also, confirm from passbolt server command line that you can connect with:

mysql -u USER -p -h region.rds.amazonaws.com

If both of these steps are validated, the next step would be to build the container, and then run this to see if access to RDS is possible from within passbolt:

docker-compose exec passbolt mysql -u USER -p -h region.rds.amazonaws.com

Hi Garrett, thanks for the greetings!

I tried the steps you described and I have access to db in both ways. Locally everything works perfectly but when I try to deploy to production the error that I posted appears.

I am sending the image to an AWS ECR e then using a container orchestrator. Locally I am using Ubuntu 20.04.

@Elias I have read elsewhere that RDS may not need the port configured. Try commenting out the DATASOURCES_DEFAULT_PORT=3306 line and see if it makes a difference. (It may not, as the port may be set to a default 3306 in passbolt. But we can experiment if this first step does not work. )

The other issue may be security settings on the AWS end of things, like a firewall setting.

Hi @garrett I fixed the problem. I had to change the file

/var/www/passbolt/vendor/robmorgan/phinx/phinx.yml

in the image and commit the changes. In that file, I changed the host parameter from localhost to the server URL, like thisScreenshot from 2021-01-19 20-42-52

1 Like

Great, so if that works maybe you will be able to revert it and use:

DATASOURCES_DEFAULT_URL

and comment out DATASOURCES_DEFAULT_HOST.

See: Database Basics - 3.9 which shows url as an alternative variable, specifically this section:

Finding a solution without hacking the source code will prevent a future issue during updates.

1 Like

Thanks @garrett it worked!

1 Like

@Elias thank you for posting the results from your work, it helps us all when you do this. Very much appreciated.

1 Like

Hi,
I am using EC2 and RDS. but my DB details are not there in ./usr/share/php/passbolt/vendor/robmorgan/phinx/src/data/Phinx/phinx.yml.dist

Trying to find the location of the db config…

Thanks

@poorni If you are still using AWS AMI as noted in your other post, it is structured differently than the Docker install as is being discussed in this thread. It is not recommended for you to look for phinx.yml.

Hi,

For AWS AMI, where i should look for db details.
My main query , after we install in my case AWS AMI, where are the config files we create during the installation process.

Thanks

Hi,

Please ignore my query. Found it