Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL on local WordPress site returns: Error 6 (Could not resolve host)

I have a local WordPress installation running at: https://catalogue3.test.

Note that all .test domains should resolve to localhost, as I use Laravel valet. When I execute the following code in my Laravel project however, I get an exception as shown below.

$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);

ConnectException

cURL error 6: Could not resolve: catalogue3.test (Domain name not found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

When I run the command below in the terminal, the WordPress page is displayed.

curl https://catalogue3.test/ --insecure
like image 965
Juliatzin Avatar asked Feb 13 '19 07:02

Juliatzin


3 Answers

I tried to add the domain to hosts and I tried to change dns in network settings, this answer is what worked for me.

Quick way to check if this is your problem is to do: curl --version and php --ri curl

The versions should match. If they don't it's probably because brew has installed curl-openssl. This can be removed by doing:

brew uninstall curl-openssl --ignore-dependencies

Maybe there's a way to configure the installed curl-openssl properly - I've not investigated this yet.

like image 129
Kash Avatar answered Sep 20 '22 23:09

Kash


Add

ip catalogue3.test

to your /etc/hosts file

like image 28
cmac Avatar answered Sep 20 '22 23:09

cmac


I solved this adding catalogue3.test to /etc/hosts, even if I was using DnsMasq, and in theory, I wouldn't need it.

like image 26
Juliatzin Avatar answered Sep 18 '22 23:09

Juliatzin