• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Error establishing a database connection [Cloud Linux, Alt-PHP]

Dmytro

Basic Pleskian
Server operating system version
CloudLinux 7.9
Plesk version and microupdate number
Plesk Obsidian 18.0.54 upd №3
Hi.
I have fully working website, for example, http://prokov.ua
If I'm changing php version to 8.2 and trying to reload data in WP Toolkit - I'm getting broken instance:

1692366248811.png

This is panel log:
Code:
[root@panel ~]# plesk ext wp-toolkit --clear-cache -instance-id 2169
[2023-08-18 16:39:55.955] 3690605:64df74ab60bf2 ERR [extension/wp-toolkit] An error occurred while executing WP-CLI command for instance: WordPress installation #2169 ('http://prokov.ua'). Error: Error establishing a database connection.

[2023-08-18 16:39:56.719] 3690605:64df74ab60bf2 ERR [extension/wp-toolkit] Failed to reset cache for the instance #2169, reason: Error: Error establishing a database connection.

Failed to reset cache for the instance #2169: Error: Error establishing a database connection.

exit status 3

PHP info contains mysql extensions data:

1692366327298.png

As I said - website is working correctly through browser, and there are no any DB errors
If I'm changing PHP to 8.1 or 7.4 - I can update data in WP Toolkit and toolkit does not show any errors:
Code:
[root@panel ~]# plesk ext wp-toolkit --clear-cache -instance-id 2169
The cache of the selected WordPress installations was cleared.


I'm using cloudlinux lsphp handler for every mentioned php versions

Please, help me to fix this
 
I can suggest that one or many of the website components (plugin or theme) do not support PHP 8.2. Can it be true? You can check it by making a clone of your website and trying to disable plugins one by one.
 
I can suggest that one or many of the website components (plugin or theme) do not support PHP 8.2. Can it be true? You can check it by making a clone of your website and trying to disable plugins one by one.
I will try this way, but as I mentioned - there’re no any “visible” problems with site and php 8.2
 
I have renamed plugin’s directory, but no effect, same error
After that I have changed in wp-сonfig.php this:

Code:
define( 'DB_HOST', 'localhost:3306' );
To this:
Code:
define( 'DB_HOST', '127.0.0.1:3306' );
And wp toolkit “update information“ functionality works like a charm.
Website correctly works with both settings.
 
Hi.
No, I didn’t any upgrade.
Mariadb version 5.5.68 and bind variable is not defined in cnf files
 
In case you have skip_name_resolve turned on in your database configuration, it could maybe help to turn if off so that names can be resolved into IP addresses.
 
what I didn’t understand:
- website is working without db errors with php 7.4/8.1/8.2
- website is working with localhost or 127.0.0.1 in config

But wp toolkit show’s error if php 8.2 active and localhost in wp-config

P.S. as I see, there’s also a difference in mysql extensions, php 8.2 has no “mysqli” but only mysqlnd/nd_mysqli and etc
 
I checked another server, it's almost the same like one I described, there's no such problem. So I'm trying to find the difference

The one I found already, as you mentioned, it's bind settings in my.cnf. This second server has:

Code:
[mysqld]
bind-address = 0.0.0.0

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
 
Unfortunately, I have no chance to do that. I will try to do and let you know

But any way, I thought if site can connect to db - so WP Toolkit should too
 
Yes, it should, but it depends on the database server name that is used. For permissions it makes a difference if this is 127.0.0.1, localhost, 127.0.0.1:3306, localhsot:3306 (although the port is the same) or maybe even using the domain name of the site. Maybe something is hardcoded into a plugin or theme.
 
Thank you for trying to help me and additional explanation, but I still do not understand why all you wrote matter in this situation:
Yes, it should, but it depends on the database server name that is used. For permissions it makes a difference if this is 127.0.0.1, localhost, 127.0.0.1:3306, localhsot:3306 (although the port is the same) or maybe even using the domain name of the site. Maybe something is hardcoded into a plugin or theme.
As I said before, website is working correctly, it has some credentials stored in wp-config.php to connect to db and website successfully connects to DB using these credentials.
In my case with both localhost and 127.0.0.1 host address, I can even try to add or remove port, but anyway - as I understood this situation , there is no any problem with permissions for db user described in wp-config.php because I can login into wordpress admin and manage my posts.
So if wp toolkit is using the same credentials - it should not have any problems too, isn't it?
 
It seems you are trying to prove that there is an issue while I am trying to focus on a solution or workaround. These are two different things. If you wish to prove that there is an issue: Yes, I agree there is some sort of issue somewhere.
 
Surely :) , but only because I found a workaround here . Thanks once again, I will update this post after I will do some more changes or tests
 
My last answer is not really a fix, because it fixes the problem for WP Toolkit (it can connect to DB after that) but not for website, website is showing "Error establishing database connection" if localhost is used as host

Fix - I added mysqli.default_socket = /var/lib/mysql/mysql.sock to php.ini and this fixed my issue for website too

Still do not understand, why php8 is not using /var/lib/mysql/mysql.sock as default value, but php7 do
 
Back
Top