Server not connecting to database

Q: DevKinsta Version
**A:Version 2.11.0 (2.11.0.7044)

Q: OS Version
**A:MacOS 13.4.1

Q: Docker Desktop Version
**A: 4.20.1 (110738)

Q: Were any error codes or messages observed? If so, what were they?
**A:

[19-Jul-2023 02:10:47 UTC] PHP Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /www/kinsta/public/ashleydouglas/wp-includes/class-wpdb.php on line 2019
[19-Jul-2023 02:10:47 UTC] PHP Stack trace:
[19-Jul-2023 02:10:47 UTC] PHP 1. {main}() /usr/local/bin/wp:0
[19-Jul-2023 02:10:47 UTC] PHP 2. include() /usr/local/bin/wp:4
[19-Jul-2023 02:10:47 UTC] PHP 3. include() phar:///usr/local/bin/wp/php/boot-phar.php:11
[19-Jul-2023 02:10:47 UTC] PHP 4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php:32
[19-Jul-2023 02:10:47 UTC] PHP 5. WP_CLI\Bootstrap\LaunchRunner->process($state = class WP_CLI\Bootstrap\BootstrapState { private $state = [‘context_manager’ => class WP_CLI\ContextManager { … }] }) phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php:78
[19-Jul-2023 02:10:47 UTC] PHP 6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php:28
[19-Jul-2023 02:10:47 UTC] PHP 7. WP_CLI\Runner->load_wordpress() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1254
[19-Jul-2023 02:10:47 UTC] PHP 8. require() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1336
[19-Jul-2023 02:10:47 UTC] PHP 9. require_wp_db() /www/kinsta/public/ashleydouglas/wp-settings.php:124
[19-Jul-2023 02:10:47 UTC] PHP 10. wpdb->__construct($dbuser = ‘root’, $dbpassword = ‘XQMObH85Nz8sibNs’, $dbname = ‘ashleydouglas’, $dbhost = ‘127.0.0.1:15100’) /www/kinsta/public/ashleydouglas/wp-includes/load.php:582
[19-Jul-2023 02:10:47 UTC] PHP 11. wpdb->db_connect($allow_bail = uninitialized) /www/kinsta/public/ashleydouglas/wp-includes/class-wpdb.php:773
[19-Jul-2023 02:10:47 UTC] PHP 12. mysqli_real_connect($link = class mysqli { public $client_info = ‘mysqlnd 7.4.33’; public $client_version = 70433; public $connect_errno = 2002; public $connect_error = ‘Connection refused’; public $errno = 2002; public $error = ‘Connection refused’ }, $host = ‘127.0.0.1’, $user = ‘root’, $password = ‘XQMObH85Nz8sibNs’, $database = NULL, $port = 15100, $socket = NULL, $flags = 0) /www/kinsta/public/ashleydouglas/wp-includes/class-wpdb.php:2019

Q: Detailed Description of the Problem
**A: Essentially after doing a sync, my site is not loading because it is not connecting to the database. My config has the correct settings but for some reason the correct database name is not being used (ie DB_NAME)

Heya Darcy :wave:

Thank you for reporting this error!
As I can see from the error logs you provided, I suspect it may be due to the “local” dbhost that’s set to 127.0.0.1:15100 in the wp-config.file on the local computer (e.g.: define( 'DB_HOST', '127.0.0.1:15100' ); ? )

Could you please check the wp-config.php file of the site in question on your local computer, and make sure to set the DB_HOST line defined there, to be the following:

define( ‘DB_HOST’, ‘devkinsta_db’ );

once saved, please try to access the local site again on your browser and see if it’s no longer showing database connection error?

Regards,
Agus

I caught that just after posting, however it has not resolved my situation. I have completed restarted DevKinsta and Docker and I am still getting the error:

This site can’t be reached

Check if there is a typo in ashleydouglas.local.
DNS_PROBE_FINISHED_NXDOMAIN

I resolved it by renaming my site (which takes a long time)
In the end, I realised it was an issue in the hosts file. Now that I now that is what is being used, I can probably resolve the state where the settings do not match the host file.

Thank you for your reply and update!
Yup, the DB_HOST issue in the wp-config.php file (should be set to devkinsta_db) I mentioned/suggested before was for the initial database connection error issue.

Glad that you have resolved that another situation or issue/DNS_PROBE_FINISHED_NXDOMAIN (which related to the host file thing)! :clap:

Cheers,
Agus

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.