H
H
Hosting Yaroslavl2020-08-12 01:25:54
PHP
Hosting Yaroslavl, 2020-08-12 01:25:54

Why instead of mysqli_connect and PDO error 504 Gateway Time-out (nginx fpm php 7.3)?

I'm trying to connect to an external server on another hosting. Everything works locally.

Tried:

$con = mysqli_connect($db_hostname, $db_username, $db_password, $db_name); 
if (mysqli_connect_errno()) { 
    echo mysqli_connect_error(); 
}

and option:
try
{
  $db  = new PDO("mysql:host=$db_hostname;dbname=$db_name", $db_username, $db_password);
  return 'ok';
}
catch (PDOException $e)
{
  echo $e->getMessage();
}


In any case, it gives out "504 Gateway Time-out"
On a PC under Windows, I installed a program to work with the database - it also connects in seconds.

Where is the mistake? Maybe somewhere in the configs there is a prohibition to look outside (although why then the error does not pop up)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-08-12
@nokimaro

And whence such confidence that a problem in PDO and in connection with base?
From the error this could be a problem in the nginx->fpm setup
Do scripts run normally if any use of PDO is removed from it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question