# Server not connecting to database

**URL:** <https://community.kinsta.com/t/server-not-connecting-to-database/2373>\
**Category:** Bug Reports\
**Created:** [July 19, 2023, 2:17am UTC](https://community.kinsta.com/t/server-not-connecting-to-database/2373 "2023-07-19T02:17:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aporia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/aporia/32/2031_2.png) [@Aporia](https://community.kinsta.com/u/Aporia)\
**Post date:** [July 19, 2023, 2:17am UTC](https://community.kinsta.com/t/server-not-connecting-to-database/2373/1 "2023-07-19T02:17:38Z")

</div>

**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)

---

<div class="post-metadata">

**Author:** ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)\
**Post date:** [July 19, 2023, 5:38am UTC](https://community.kinsta.com/t/server-not-connecting-to-database/2373/2 "2023-07-19T05:38:47Z")

</div>

Heya Darcy 👋

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

---

<div class="post-metadata">

**Author:** ![Aporia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/aporia/32/2031_2.png) [@Aporia](https://community.kinsta.com/u/Aporia)\
**Post date:** [July 21, 2023, 3:29am UTC](https://community.kinsta.com/t/server-not-connecting-to-database/2373/3 "2023-07-21T03:29:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)\
**Post date:** [July 21, 2023, 5:13am UTC](https://community.kinsta.com/t/server-not-connecting-to-database/2373/4 "2023-07-21T05:13:54Z")

</div>

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)! 👏

Cheers,  
Agus

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/80f8c4e56fecc02327a0964e6bf63a716483529f.png) [@system](https://community.kinsta.com/u/system)\
**Post date:** [July 23, 2023, 5:14pm UTC](https://community.kinsta.com/t/server-not-connecting-to-database/2373/5 "2023-07-23T17:14:06Z")

</div>

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