Laravel guzzle cURL error 6: Failed to resolve host: http (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

In my development, my code works correctly. When I click on my server, it becomes an error.

cURL error 6: Could not resolve host: http (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Here is my code:

 use GuzzleHttp\Client; try { $client = new Client(); $client->request('POST', env('API_DOMAIN') . '/v1/user/auth/verified_email', ['headers' => ['Authorization' => 'cm9vcGlhLnVzZXIud2ViOkY0RVN3VXJheS1qVVB1a18='], 'query' => ['token' => $key]]); return redirect('/')->with('status', 'Your email has been verified. Thanks!')->with('statusType', 'success'); } catch (ConnectException $e) { Log::error($e); return redirect('/'); } 

Any solution?

thanks

+6
source share
4 answers

My solution is to clear all types of caches in Artisan.

Run these commands together:

 php artisan route:clear php artisan config:clear php artisan cache:clear 
+3
source

I spent the whole day to find that the best practice is to actually catch the Exceptions as follows:

 catch(\Exception $ex) 

It matters! therefore DO NOT use:

 catch(Exception $ex) 

You can put this catch at the end where all other specific exceptions are caught.

+2
source

Perhaps your API_DOMAIN was not configured to the correct URL (it started with http: // or https: //)?

It might be worth trying to restart the web server (for example, restart nginx).

It could also be a connection problem on your server. You can try restarting the VPS or checking if the firewall has blocked your outgoing request. Perhaps turn off iptables or firewalld for a moment.

DNS issues for API_DOMAIN may also occur. You may have configured it locally in your / etc / hosts in your development environment, but not in production. You can check if dns is resolved correctly or add it to the / etc / hosts file on your production server.

+1
source

This answer helped me. It turned out that this is a mismatch between curl versions for OSX. Each had an openssl version. A nightmare to find, but a direct solution. See fooobar.com/questions/17918261 / ...

0
source

All Articles