cURL error 6: Could not resolve host laravel

I use the laravel HTTP client. Periodically there is an error cURL error 6: Could not resolve host, tell me how to fix it?

use Illuminate\\Support\\Facades\\Http;

$response = Http::get('http://example.com');

Upvotes: 2

Views: 14972

Answers (3)

Khalil
Khalil

Reputation: 225

in my case for some reason I set PUSHER_HOST=http in .env file. Removing the http and making it PUSHER_HOST= solved the issued.

Upvotes: 0

rohit kumar
rohit kumar

Reputation: 11

This is a problem with your system. You should autoload your packages. This may solve your problem. use this command

composer dump-autoload

Upvotes: 1

Jacint Simko
Jacint Simko

Reputation: 56

I think it is a network related problem. I guess your ISP cannot resolve "http://example.com". Your code is working on my environment!

On which OS you are trying to run this code?

On linux based OS and if you are using apache2 as web server you can try below steps:

Open resolv.conf

vi /etc/resolv.conf

Add these lines(Google nameservers) to the file

nameserver 8.8.8.8

nameserver 8.8.4.4

Then restart apache2

/etc/init.d/apache2 restart

Upvotes: 4

Related Questions