Docker Community Forums

Share and learn in the Docker community.

WordPress Database issue when using PHP-FPM Container


(Adakun) #1

Apache 2.4 (Host)
I have enabled fcgi module so Apache can listen for php-fpm

PHP-FPM installed (Docker Container)
docker run -it -d --name phpfpm -p 9000:9000 -v /var/www/html:/var/www/html bitnami/php-fpm

WordPress (Host)
installed in /var/www/html
I have confirmed the DB credentials are correct in wp-config.php

MySQL (Host)
Listening on

I know the php-fpm container is working because when I place an info.php in the document root, the browser displays it correctly, but when I try to run WordPress through the browser I get:
“Error establishing a database connection”

Has any anyone experienced this before? I have a belief it may be some configuration I’m missing with MySQL. Let me know if you guys have any idea’s of what the issue may be.


(Foolab) #2

Same problem here on a VPS (not docker).

Other php script can connect to the mysql db… wordpress can’t!
Credentials are correct, verified connecting to phpmyadmin.

have you solved in some way?

(Sam) #3

this means that mysql will ONLY accept requests from the adapter where exists.
a container has its OWN ip address, and would NOT BE

you need to change this to


for any source ip address in the mysql config.

(Sam) #4

can u provide more info on the system design, what runs where, how many containers, running what.
I do not know what VPS is myself.

what does ‘other’ mean?

(Foolab) #5

I’m not using Docker but I got the same problem as @adakun.

I found a possible solution (I’m not using Apache)… Wordpress by default asks for a socket connection: