I'm facing this very odd error. I can't send a cURL request anymore after changing nothing. Out of the sudden I'm getting:
'Could not resolve host: hostname'
I know there are like a 1000 instances of this question on stackoverflow but I have tried all the suggested answers/comments in them for the past 5 hours and nothing seems to work. This is my code for the request:
<?php
class APIService
{
private $host;
private $key;
function __construct($host, $key)
{
$this->host = $host;
$this->key = $key;
}
function curlRequest($config)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('api:'.$this->key));
curl_setopt($ch, CURLOPT_URL, $this->host.$config);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curlSession = curl_exec($ch);
return $this->decodeJSON($curlSession);
}
function getSomeList()
{
return $this->curlRequest('/folder/list');
}
private function decodeJSON($someList)
{
return json_decode($someList, true);
}
}
The host is local and using docker ps
I can see that is running. Everything worked fine a few days ago and I made absloutly no changes to it or to any component that may have an effect on it but it doesn't work out of the sudden. Has anyone has any ideas why this is happening and how I could fix it?