# PHP Curl unable to resolve some hosts

**URL:** https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175
**Category:** Bug Reports
**Created:** [March 29, 2023, 9:55am UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175 "2023-03-29T09:55:02Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jdgcss](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/jdgcss/32/1862_2.png) [@jdgcss](https://community.kinsta.com/u/jdgcss)
#### Post date: [March 29, 2023, 9:55am UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/1 "2023-03-29T09:55:02Z")

</div>

**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](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:

```auto
<?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](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!

\*\*

---

<div class="post-metadata">

### Author: ![jdgcss](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/jdgcss/32/1862_2.png) [@jdgcss](https://community.kinsta.com/u/jdgcss)
#### Post date: [March 29, 2023, 9:55am UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/2 "2023-03-29T09:55:40Z")

</div>

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

> [@Unable to resolve host address 'storage.googleapis.com'](https://community.kinsta.com/t/unable-to-resolve-host-address-storage-googleapis-com/1717/1):
>
> Q: Date/Time this occurred (Provide your time zone also) A: Not time specific Q: DevKinsta Version A: 2.7.0 Q: OS Version A: MacOS Monterey 12.5.1 (21G83) Q: Docker Desktop Version A: 4.12.0 (85629) Q: Were any error codes or messages observed? If so, what were they? A: unable to resolve host address ‘[storage.googleapis.com](http://storage.googleapis.com)’ Q: Detailed Description of the Problem A: See below While doing some development work using download\_url() to download an external file from our GCP storage acco…

> [@Curl can't resolve host: img.youtube.com](https://community.kinsta.com/t/curl-cant-resolve-host-img-youtube-com/1895):
>
> Q: Date/Time this occurred (Provide your time zone also) A: Discovered this on 22 Nov 2022, 15:00, Sao Paulo, BR time. Q: DevKinsta Version A: 2.8.0 Q: OS Version A: MacOS Monterey, 12.6 (Running on M1 machine) Q: Docker Desktop Version A: v4.13.1 Q: Were any error codes or messages observed? If so, what were they? A: curl: (6) Could not resolve host: [img.youtube.com](http://img.youtube.com) Q: Detailed Description of the Problem A: We have a script that calls the url [https://img.youtube.com](https://img.youtube.com) to retrieve the t…

---

<div class="post-metadata">

### Author: ![Alessandro](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/alessandro/32/2310_2.png) [@Alessandro](https://community.kinsta.com/u/Alessandro)
#### Post date: [March 29, 2023, 10:59am UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/3 "2023-03-29T10:59:42Z")

</div>

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

Regards,  
Alessandro

---

<div class="post-metadata">

### Author: ![jdgcss](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/jdgcss/32/1862_2.png) [@jdgcss](https://community.kinsta.com/u/jdgcss)
#### Post date: [March 29, 2023, 11:37am UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/4 "2023-03-29T11:37:56Z")

</div>

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:

```auto
curl https://kingspuk000restprod.tnhs.cloud

```

and get this response:

```auto
<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:

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

```

then

```auto
/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](http://storage.googleapis.com)

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

```auto
:/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?

---

<div class="post-metadata">

### Author: ![Alessandro](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/alessandro/32/2310_2.png) [@Alessandro](https://community.kinsta.com/u/Alessandro)
#### Post date: [March 29, 2023, 12:25pm UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/5 "2023-03-29T12:25:17Z")

</div>

👆 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 🤞

---

<div class="post-metadata">

### Author: ![Alessandro](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/alessandro/32/2310_2.png) [@Alessandro](https://community.kinsta.com/u/Alessandro)
#### Post date: [March 29, 2023, 12:33pm UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/6 "2023-03-29T12:33:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jdgcss](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/jdgcss/32/1862_2.png) [@jdgcss](https://community.kinsta.com/u/jdgcss)
#### Post date: [March 29, 2023, 12:59pm UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/8 "2023-03-29T12:59:09Z")

</div>

> [@Alessandro](#):
>
> dns\_server add -d kingspuk000restprod.tnhs.cloud -A xxx.xxx.xxx.xxx

Thank you SO MUCH - this worked like a charm 👍

---

<div class="post-metadata">

### Author: ![Alessandro](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/alessandro/32/2310_2.png) [@Alessandro](https://community.kinsta.com/u/Alessandro)
#### Post date: [March 29, 2023, 1:01pm UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/9 "2023-03-29T13:01:18Z")

</div>

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

Regards,  
Alessandro

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/80f8c4e56fecc02327a0964e6bf63a716483529f.png) [@system](https://community.kinsta.com/u/system)
#### Post date: [April 1, 2023, 1:01pm UTC](https://community.kinsta.com/t/php-curl-unable-to-resolve-some-hosts/2175/10 "2023-04-01T13:01:41Z")

</div>

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