phpList / phplist-docker

Dockerised version of phpList
33 stars 18 forks source link

Cannot connect to database, Sql server is not running. Please check your configuration or contact the administrator. #5

Closed LTepliakov closed 4 years ago

LTepliakov commented 5 years ago

Hello team. I have just tried to install it according to instructions in Readme. Now I can see three containers running: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a6769a2f514b phplist/phplist:latest "docker-entrypoint.sh" 5 hours ago Up 5 hours 443/tcp, 0.0.0.0:8000->80/tcp phplist-docker_phplist_1 9ffce3a83e8a phplist/postfix:latest "sh -c 'service rsys…" 5 hours ago Up 5 hours 25/tcp, 465/tcp, 587/tcp phplist-docker_mailhost_1 2046e6f7fa37 mariadb:10.1 "docker-entrypoint.s…" 5 hours ago Up 5 hours 3306/tcp phplist-docker_dbhost_1

But when I try to go to the link http://localhost:8000/lists/admin/, I get: Sql server is not running. Please check your configuration or contact the administrator.

Appreciate any advice on how to start troubleshooting?

michield commented 5 years ago

the best way to trouble shoot is to go into the container.

docker exec -it [containerid] bash

and then check the networking, and config.php file

The Docker filies are all in this repository. It may be useful to try one of the docker-compose ones, as they bring it all up in a network configuration

docker-compose -f [file.yml] up -d

atropo commented 5 years ago

I've got the same problem.

In my tests I see that this happens only with the latest image. If I use image: phplist/phplist:3.4.1 in phplist.yml everyhing works fine.

Inspecting the code I see that the error happens in lists/admin/mysqli.inc, the $errno in 2002.

Doing some tests happens that in function Sql_Connect($host, $user, $password, $database) the $host has value localhost, so phplist is trying to connect to a local db and not to the phplist-docker_dbhost_1.

If, in the code, put the address of the db_container in $host everything works again.

nzomedia commented 4 years ago

Bonjour, i'm facing the same issue currently, in the phplist container, in config/config.php i got: $database_host='localhost'. I edited the value of this variable to 'dbhost' and everything works.

I wonder how is the config file generated, i fail to figure it out in the phplist Dockerfile repository.

Can someone explain me how to solve this issue, i think that as soon as i restart the services i may lose the edit that i made.

bizmate commented 4 years ago

@michield it looks like this is an issue/bug given by this line https://github.com/phpList/phplist-docker/blob/master/phplist/Dockerfile#L31

Not sure why the template configuration based on environment variables is copied this way but indeed it should go under public_html/lists .

Can this please be re-opened?

michield commented 4 years ago

The location of the config file is set in the Apache Vhost

https://github.com/phpList/phplist-docker/blob/master/phplist/docker-apache-phplist.conf#L5

michield commented 4 years ago

This is presumably now resolved with #9