Skip to content
Advertisement

docker-compose, WordPress and MariaDB, PHP Fatal error: Uncaught mysqli_sql_exception: Connection refused

I have a WP project with following docker-compose configuration. When I try to connect my http://localhost to access the installation, I get 500 and I read this in the log:

PHP Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/www/html/web/wp/wp-includes/wp-db.php

I assume there is something wrong with the ip or the host but the weird thing is that phpmyadmin is working fine, and it connects with mysql without issues.

JavaScript

My wordpress .env, among the other settings, set the host like the following:

DB_HOST="mysql:3307"

But I also tried

DB_HOST="mysql:3306"

or simply

DB_HOST="mysql"

Do you have any suggestions?

Thanks.

Advertisement

Answer

your WordPress Instance and MySQL Instance isn’t connected. Try adding networks on the docker-compose.yml

JavaScript

and on the bottom of the file add:

JavaScript

this is the way to configure docker to be connected each other

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement