Today my cURL is starting to show me this error Could not resolve: {local-domain.test} (domain name not found)
All working fine if I'm trying to get some info from an external link, but local sites aren't working properly.
So, here is my code
public function send($type, $url, $data)
{
$type = strtolower($type);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($type == 'post') {
$urlWithData = http_build_query($data);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlWithData);
}
$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$out = new \stdClass();
$out->status = $status;
$out->body = json_decode($result, true);
return $out;
}
All start to work if I will add that host into my /etc/hosts/ file but I have a huge list of the domain and before updating PHP all worked fine on my side. I'm using dnsmasq as a dynamic host resolving tool.
- OS: MacOs High Siera
- Apache: 2.4.37
- PHP: Multiple PHP versions, from 5.6-7.3
Some debug info:
- Ping to that domain from the terminal is working fine (showing localhost)
- Everything is working fine even If I run
curl -v local-domain.test
from a terminal - I've tried to use
CURLOPT_DNS_USE_GLOBAL_CACHE
option. - Cleared all DNS cache of my machine from a terminal
Maybe I forgot to add something to the php.ini
of each PHP? Also, all worked fine before I've made updating process of them all.