• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question [REST API] Getting ERR::Connection Refused PHP

To be honest, I think this might be an issue related to Plesk itself. Because, as far as I can see, this issue only happens when you execute the code from the same server you're running Plesk on. I suspect I has something to do with the fact that php-fpm restarts when you add a new domain. Hence the 503 error, and thats also why this issue doesn't happen when you run the code from a remote/local machine.

Not necessarily a bug, but I would say it is certainly undesirable behaviour. I am also not sure if there is a solution to this issue.

@IgorG, do you maybe have any suggestions?
Maybe if you run the Curl request with a Proxy, would that make any difference?
I can only say that this is a very specific usage scenario and such things need to be investigated directly on the affected server.
Therefore, I would advise you to contact Plesk support.
I will contact them, thank you
 
I've ran some more tests. It definitely seems to be related to FPM. From the PHP-FPM log:
[18-Mar-2021 10:47:32] NOTICE: ready to handle connections [18-Mar-2021 10:47:32] NOTICE: systemd monitor interval set to 10000ms [18-Mar-2021 10:47:33] NOTICE: [pool plesk-php73-fpm.plesk-service.localdomain] child 28449 exited with code 0 after 0.031291 seconds from start [18-Mar-2021 10:47:33] NOTICE: [pool plesk-php73-fpm.plesk-service.localdomain] child 28463 started

@safemoon When you switch your PHP to FastCGI you won't encounter this issue. Which might not be desirable, in that case contact Plesk support (and let us know their solution).
I still get the same error in FastCGI PHP 7.3.5
 
I switched the PHP handler from FPM to FastCGI on the PHP settings of the domain.
Schermafbeelding 2021-03-18 om 13.56.16.png

For me the CURL call runs without any issue after switching. I my case nginx is also disabled.
 
I switched the PHP handler from FPM to FastCGI on the PHP settings of the domain.
View attachment 18501

For me the CURL call runs without any issue after switching. I my case nginx is also disabled.
Unfortunately, this does not work for me. How do you run the php script? I just visit the path from my browser "example.com/file.php"
To be more precise it's a subdomain so the url looks like this: "sub.example.com/file.php" I've changed the PHP version for the master and subdomain but still the same result.

Any other advices?
Thank you for your support.
 
What Plesk version are you using?

Try enabling the "Apache graceful restart" option in Tool & Settings > Apache Web Server Settings if it's not yet enabled. I am not even sure if its a related setting, but I guess it's worth a try.

Just like you I just visit the file from my browser; "example.com/file.php".

PHP:
$url = "https://server.net:8443/api/v2/domains/";
$fields = array(
  "name" => "example5.com",
  "description"=> "My website",
  "hosting_type"=> "virtual",
  "hosting_settings"=> array(
    "ftp_login"=> "test_login5",
    "ftp_password"=> "changeme1Q**"
  ),
  "owner_client"=> array(
    "id"=> 2,
    "login"=> "owner25",
    "guid"=> "b623e93d-dc72-4102-b5f0-ded427cf0fb1",
    "external_id"=> "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
  ),
  "ipv4"=> array(
    "123.123.123.123"
  ),
  "ipv6"=> array(
    "aaaa:bbbb:cccc:dddd:eeee"
  ),
  "plan"=> array(
    "name"=> "Unlimited"
  )
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json","cache-control: no-cache","Accept: application/json"));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "admin:password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result     = curl_exec ($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
 
What Plesk version are you using?

Try enabling the "Apache graceful restart" option in Tool & Settings > Apache Web Server Settings if it's not yet enabled. I am not even sure if its a related setting, but I guess it's worth a try.

Just like you I just visit the file from my browser; "example.com/file.php".

PHP:
$url = "https://server.net:8443/api/v2/domains/";
$fields = array(
  "name" => "example5.com",
  "description"=> "My website",
  "hosting_type"=> "virtual",
  "hosting_settings"=> array(
    "ftp_login"=> "test_login5",
    "ftp_password"=> "changeme1Q**"
  ),
  "owner_client"=> array(
    "id"=> 2,
    "login"=> "owner25",
    "guid"=> "b623e93d-dc72-4102-b5f0-ded427cf0fb1",
    "external_id"=> "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
  ),
  "ipv4"=> array(
    "123.123.123.123"
  ),
  "ipv6"=> array(
    "aaaa:bbbb:cccc:dddd:eeee"
  ),
  "plan"=> array(
    "name"=> "Unlimited"
  )
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json","cache-control: no-cache","Accept: application/json"));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "admin:password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result     = curl_exec ($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
OS ‪Ubuntu 14.04.6 LTS‬
Product Plesk Onyx Version 17.8.11 Update #53, last updated on Feb 14, 2020 06:29 AM
 
What Plesk version are you using?

Try enabling the "Apache graceful restart" option in Tool & Settings > Apache Web Server Settings if it's not yet enabled. I am not even sure if its a related setting, but I guess it's worth a try.

Just like you I just visit the file from my browser; "example.com/file.php".

PHP:
$url = "https://server.net:8443/api/v2/domains/";
$fields = array(
  "name" => "example5.com",
  "description"=> "My website",
  "hosting_type"=> "virtual",
  "hosting_settings"=> array(
    "ftp_login"=> "test_login5",
    "ftp_password"=> "changeme1Q**"
  ),
  "owner_client"=> array(
    "id"=> 2,
    "login"=> "owner25",
    "guid"=> "b623e93d-dc72-4102-b5f0-ded427cf0fb1",
    "external_id"=> "b623e93d-dc72-4102-b5f0-ded427cf0fb1"
  ),
  "ipv4"=> array(
    "123.123.123.123"
  ),
  "ipv6"=> array(
    "aaaa:bbbb:cccc:dddd:eeee"
  ),
  "plan"=> array(
    "name"=> "Unlimited"
  )
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json","cache-control: no-cache","Accept: application/json"));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "admin:password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result     = curl_exec ($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
"Apache graceful restart" option is missing from my server. I will try to order a new dedicated server with the latest Plesk and Ubuntu version. Hopefully it will work.
 
"Apache graceful restart" option is missing from my server. I will try to order a new dedicated server with the latest Plesk and Ubuntu version. Hopefully it will work.
The above option with FastCGI made the script work!! Finally. Are there any downsides when this option is enabled?
Thank you
 
BTW, Graceful restart for Apache is enabled by default on all new Plesk Obsidian installations.
 
> The above option with FastCGI made the script work!! Finally. Are there any downsides when this option is enabled?

No. In fact, a graceful restart is highly recommended for production.

Graceful = apache waits for gracefulrestarttimeout for all children to quit. Then sends SIGKILL if they didn't.

Non-graceful = immediate SIGKILL

The latter will result in active connections being dropped and 5XX errors.
 
Back
Top