PHP Curl unable to resolve some hosts

Q: Date/Time this occurred (Provide your time zone also)
A: 28/03/2023 - 3pm

Q: DevKinsta Version
A: 2.10.0 (2.10.0.6571)

Q: OS Version
**A: Mac OSX Ventura 13.2.1 (22D68) **

Q: Docker Desktop Version
**A: 4.17.0 (99724) **

Q: Were any error codes or messages observed? If so, what were they?
**A: Curl error: Error cURL error 6: Could not resolve host: kingspuk000restprod.tnhs.cloud (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) **

Q: Detailed Description of the Problem
**A: I have been working on a REST API integration using Guzzle and it suddenly stopped working and throwing the above cURL error6. The API sits at https://kingspuk000restprod.tnhs.cloud and has been working correctly for weeks. I can connect to it fine from Postman and from the same PHP code running under MAMP. For debugging I created a very simple curl script:

<?php 
$handle = curl_init(); 
$url = "https://kingspuk000restprod.tnhs.cloud/"; 
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($handle) === false) {
    echo 'Curl error: ' . curl_error($handle);
} else {
    echo 'Operation completed without any errors';
} 
curl_close($handle);
die();
?>

If I change the url in the above test script to https://storage.googleapis.com It also can;t resolve the host.

I’ve tried chaining my network name servers to use Google’s but still no luck.

Please can anyone help tell me why it wont resolve the host domain?

I don’t want to have to use MAMP!

**

I found these two posts here that suggest I’m not alone with this issue:

Hey @jdgcss,
I am not able to replicate the issue :thinking: I get a proper response when using curl against that domain. Anyway, have you tried the workaround suggested in the other thread?

Regards,
Alessandro

1 Like

Hi @Alessandro

Thanks for replying.

Yes I’ve tried a few things from there. here’s an overview.

If I open up a terminal window I can do this:

curl https://kingspuk000restprod.tnhs.cloud

and get this response:

<html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow">
<script src="/_Incapsula_Resource?SWJIYLWA=5074a744e2e3d891814e9a2dace20bd4,719d34d31c8e3a6e6fffd425f7e032f3">
</script>
<body>
</body></html>

Which is as expected. Now if I follow the solution in the other threads I can do this:

docker exec -it devkinsta_fpm bash
www/kinsta# curl storage.googleapis.com
Could not resolve host: storage.googleapis.com

then

/www/kinsta# dns_server update -d storage.googleapis.com
{"domain":"storage.googleapis.com.","records":[{"ttl":60,"class":"IN","type":"A","address":""}]}
curl https://storage.googleapis.com
<?xml version='1.0' encoding='UTF-8'?><Error><Code>MissingSecurityHeader</Code><Message>Your request was missing a required header.</Message><Details>Authorization</Details></Error>

so that solution correctly fixes the DNS issue with storage.googleapis.com

However - if I try the same with my REST Api domain:

:/www/kinsta# dns_server update -d kingspuk000restprod.tnhs.cloud
{"domain":"kingspuk000restprod.tnhs.cloud.","records":[{"ttl":60,"class":"IN","type":"A","address":""}]}
:/www/kinsta# curl https://kingspuk000restprod.tnhs.cloud
curl: (6) Could not resolve host: kingspuk000restprod.tnhs.cloud

Why would it fix one and not the other do you think?

:point_up_2: that’s odd, unfortunately without being able to replicate here it’s hard to check but perhaps we can try a different workaround, by editing the host file for devkinsta_fpm.

Give it a try editing the /etc/hosts file in docker and manually specify what is the IP address that kingspuk000restprod.tnhs.cloud should point to.

Let us know how it goes or you need the steps needed to edit that file :crossed_fingers:

You might also want to try to add the DNS host directly as in:

dns_server add -d kingspuk000restprod.tnhs.cloud -A xxx.xxx.xxx.xxx

where xxx.xxx.xxx.xxx is the IP address of that domain.

Thank you SO MUCH - this worked like a charm :+1:

That’s great to hear! You are very welcome!

Regards,
Alessandro

1 Like

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