12

On my development my code is working properly. When I push to my server it become 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

4
  • 6
    have you set API_DOMAIN in your .env ? Commented Aug 12, 2016 at 2:51
  • Restart the server. After two hours that was what worked for me. Commented Mar 21, 2017 at 18:15
  • I restarted server, problem happened again. Commented Mar 23, 2017 at 3:20
  • Did u solve this problem bro? Commented Aug 9, 2019 at 14:12

7 Answers 7

16

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

Run these commands together:

php artisan route:clear
php artisan config:clear
php artisan cache:clear
Sign up to request clarification or add additional context in comments.

Comments

3

I spent a day to find that the best practice is to actually catch Exceptions in the following manner:

catch(\Exception $ex)

That \ makes all the difference! so DO NOT use :

catch(Exception $ex)

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

1 Comment

Please, read about Namespaces, as this not about ``, but about Namespaces you've used wrong
1

Your API_DOMAIN may not have been set to a proper url (did it start with http:// or https://)?

It may also be worth a try to restart the web server (e.g. restart nginx).

It could also be a connectivity issue on your server. You can try a reboot of the VPS or check if the firewall did not block your outgoing request. Maybe disable iptables or firewalld for a moment.

There could also be issues with the DNS for the API_DOMAIN. Maybe you did configure it locally in your /etc/hosts on your developmnet environment but not on production. You may check if the dns resolves properly or add it to your /etc/hosts file on your production server.

Comments

1

This answer helped me. It turned out to be a disparity between curl versions on OSX. Each had a version of openssl being used. Nightmare to find but a straightforward fix. See https://stackoverflow.com/a/54908305/2867894

Comments

1

Do

php artisan optimize:clear

to clear all caches in laravel

Comments

0

I had this issue recently and it turns out that I was tunneling through a proxy server. I stopped routing through a proxy and it worked just fine.

Comments

-1

Just run your web server, I had the same error but my server was OFF, then I turn it on, and it works for me

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.