Curl Error Using Guzzle using Laravel Valet and Passport

This is a niche issue with: Laravel, Valet, Passport, Guzzle, Curl, API

If you’re using Laravel Passport and you’re doing something like this:


use GuzzleHttp\Client;

try {
    $client = new Client();
    $client->post('site.test/oath/token', [some params]);

And you get an error “Laravel guzzle cURL error 6: Could not resolve host” while making an api post request. Check these two things.

One of the two should work.

Make sure your curl version and php curl version match

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

Add your .test site to host

For Mac users open your “/etc/hosts” file and add this to the bottom.

127.0.0.1 example.test

On Windows it’s “C:\Windows\System32\drivers\etc”

Leave a Comment