H2CK / webtrees

Docker Image containing Webtrees
Apache License 2.0
36 stars 9 forks source link

Problem connecting to MySQL database #62

Closed thyholm1234 closed 1 year ago

thyholm1234 commented 1 year ago

Not sure if this is the right place searching for help.

Overnight my installation of webtrees stopped working so I decided to do a fresh install - still using the same database and location for the data files.

When running the docker container with:

docker run -d -p 8089:8079 --name webtrees -e BASE_URL=https://mywebsite.com -v /webtrees/data:/var/www/html/data -e GROUP_ID=999 -e PORT=8079 -e DB_USER=root -e DB_PASSWORD=**** -e DB_HOST=172.20.0.2 -e DB_PORT=3306 -e DB_NAME=webtrees --restart always dtjs48jkt/webtrees:2.1.16

I get this error:

`RuntimeException: SQLSTATE[HY000] [2002] No route to host in /var/www/html/app/Http/Middleware/UseDatabase.php:119

Stack trace: #0 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDatabase->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

1 /var/www/html/app/Http/Middleware/BadBotBlocker.php(282): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

2 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

3 /var/www/html/app/Http/Middleware/CompressResponse.php(73): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

4 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CompressResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

5 /var/www/html/app/Http/Middleware/ContentLength.php(40): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

6 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ContentLength->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

7 /var/www/html/vendor/middlewares/client-ip/src/ClientIp.php(65): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

8 /var/www/html/app/Http/Middleware/ClientIp.php(47): Middlewares\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

9 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

10 /var/www/html/app/Http/Middleware/HandleExceptions.php(90): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

11 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

12 /var/www/html/app/Http/Middleware/BaseUrl.php(73): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

13 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

14 /var/www/html/app/Http/Middleware/ReadConfigIni.php(68): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

15 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

16 /var/www/html/app/Http/Middleware/SecurityHeaders.php(48): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

17 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

18 /var/www/html/app/Http/Middleware/EmitResponse.php(57): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

19 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher))

20 /var/www/html/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest))

21 /var/www/html/app/Webtrees.php(275): Middleland\Dispatcher->dispatch(Object(Nyholm\Psr7\ServerRequest))

22 /var/www/html/app/Webtrees.php(262): Fisharebest\Webtrees\Webtrees::dispatch(Object(Nyholm\Psr7\ServerRequest), Array)

23 /var/www/html/index.php(51): Fisharebest\Webtrees\Webtrees->httpRequest()

24 {main}`

I'm able to access the database from the container so I don't think it's firewall related.

H2CK commented 1 year ago

Based on the error SQLSTATE[HY000] [2002] No route to host I would assume an network connectivity issue.

How did you check the connectivity from the Webtrees container to the MySQL database? Could you please check if the file /var/www/html/data/config.ini.php exists and contains the correct settings for the database connection.

Once this file exists it is not possible to modify the Webtrees DB settings via the environment variables! If you want to change the db connection you should do this via the web interface or in the mentioned file directly.

thyholm1234 commented 1 year ago

@H2CK a quick edit of the config.ini.php solved the issue. Thank you for helping out.