Ralph J. Smit Laravel Software Engineer
Stripe is a terrific company for developers. Their API's and developer-facilities are absolutely the best. One of those awesome things Stripe offers, is the Stripe CLI. This is a Command-line tool which you can use on your local device to test and simulate webhooks easily.
However, the Stripe CLI doesn't immediately work with Laravel Valet. Valet is an awesome tool as well, but sometimes not all awesomeness is able to work together.
After some googling and debugging, I luckily found an easy fix to get the Stripe CLI working with Laravel Valet.
1. Update your /etc/hosts file
For this example, let's say that our Laravel Valet domain is called
To make the Stripe CLI work with Laravel Valet, we need to make a little change to your hosts file. If you haven't heard of this before, the hosts-file is a small file on your computer that you can use to map a domain to a specific IP. So it basically allows you to override certain DNS-settings.
Anyway, that complex talk doesn't matter now. You should open your hosts file from
/etc/hosts. This file needs sudo-access, so the easiest way is to edit it with the Nano-editor.
sudo nano /etc/hosts
If you don't like the Nano-editor, you can open the file in a text-editor as well:
sudo open /etc/hosts
Next, you should add the following rule to your
/etc/hosts file (substitute
stripe.test for your domain):
Next, save the file.
2. Flush the DNS cache
Usually, such DNS/IP-settings are cached for a while, so that your computer will be faster. To flush the DNS-cache, run:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
You might also need to clear your browser cache/cookies.
3. Use Stripe CLI with Laravel Valet ⚡️
Now you are ready to use the Stripe CLI with Laravel Valet. For example, if you're using Laravel Cashier with Stripe, you can use the following command to forward webhooks to your local application as well:
stripe listen --forward-to https://stripe.test/stripe/webhook
As you've seen, it really isn't difficult to get the Stripe CLI to work with Laravel Valet. However, when I encountered this the first time, it took me a while to figure it all out. Happy developing!