Symptoms
In an attempt to open site example.com the following error appears:
504 Gateway Time-out
nginx
The domain uses FPM application served by Apache or FPM application served by nginx handler in Plesk > Domains > example.com > PHP Settings and below error can be found in corresponding /var/log/plesk-phpXX-fpm/error.log
, where XX – PHP version:
# cat /var/log/plesk-php74-fpm/error.log | grep example.com
WARNING: [pool example.com] child 5833 said into stderr:
“NOTICE: PHP message: PHP Warning: mysql_connect(): Can’t connect to MySQL server on ‘mysql.somehostname.com’ (4) in /var/www/vhosts/example.com/httpdocs/php/connect-mysql.php on line 11”
WARNING: [pool example.com] child 26883 said into stderr: “NOTICE: PHP message: PHP Warning: mysql_connect(): Connection timed out in /var/www/vhosts/example.com/httpdocs/php/connect-mysql.php on line 11”
Cause
MySQL connection settings in the mentioned php file are wrong.
Resolution
- Login to the server via SSH.
- Open file specified in
/var/log/plesk-phpXX-fpm/error.log
. In this case it’s/var/www/vhosts/example.com/httpdocs/php/connect-mysql.php
. Find username, its password and host, it can look like below:7 DEFINE ('DB_USER', 'user');
8 DEFINE ('DB_PSWD', 'password');
9 DEFINE ('DB_HOST', 'mysql.somehostname.com');
10 DEFINE ('DB_NAME', 'database');
11 $conn = mysql_connect(DB_HOST,DB_USER,DB_PSWD) or die("error to connect server"); - Check that parameters
DB_USER, DB_PASSWORD
andDB_NAME
are correct. It must be possible to connect to database:# mysql -u “user” -p “password” “database” -h “mysql.somehostname.com”
If the command above fails with the next error:
# mysql -u “user” -p “password” “database” -h “mysql.somehostname.com”
ERROR 1045 (28000): Access denied for user ‘user’@’localhost’ (using password: YES)then some of parameters
user
,Âpassword
,Âdatabase
 are not correct. Verify them and change if necessary.Note: If database was created in Plesk user and password can be changed in Plesk > Domains > example.com > Databases