stripe / stripe-cli

A command-line tool for Stripe
https://stripe.com/docs/stripe-cli
Apache License 2.0
1.59k stars 373 forks source link

No such host #50

Closed MrMooky closed 5 years ago

MrMooky commented 5 years ago

I am receiving events but also receive errors when trying to reach the local app. Setup is Laravel 5.7 with Homebrew and Valet.

Ready! Your webhook signing secret is whsec... [Sun, 21 Jul 2019 13:52:21 CEST] INFO Received event: evt_1EydaSJFP015mQcJpyAozhkF [type: payment_intent.created] [Sun, 21 Jul 2019 13:52:21 CEST] ERROR Failed to POST event to local endpoint, error = Post https://myappname.test/hooks/stripe/paymentintent: dial tcp: lookup friendships.test on MYIP:53: no such host

ob-stripe commented 5 years ago

@MrMooky This likely isn't an issue with the CLI, it means that the hostname you're using (friendships.test) cannot be resolved by your nameserver at 192.168.2.1. You can confirm this by running e.g. ping friendships.test.

You might need to manually add the IP for friendships.test in your /etc/hosts file, or configure your DNS server to properly resolve the domain name.

Closing, but feel free to reply with more information if you believe this is actually an issue with the CLI.

MrMooky commented 5 years ago

@ob-stripe Thanks for your feedback. I tried adding the IP to the hosts file, but my Laravel app just went "offline" when doing so. When I ping my local url with ping friendships.test I get 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.026 ms.

Where does the Stripe CLI get the other IP from? And how could I manage to make Stripe CLI use the regular localhost IP?

stripe listen --forward-to localhost or stripe listen --forward-to 127.0.0.1 didn't do the trick. Is this something I should ask the Laravel guys instead?

ob-stripe commented 5 years ago

@MrMooky The 192.168.2.1 IP probably comes from your /etc/resolv.conf file, which is where DNS servers are declared.

Can you try running the CLI with export GODEBUG=netdns=1 and share the results here?

MrMooky commented 5 years ago

@ob-stripe How to? ._. Running stripe export GODEBUG=netdns=1 results in unknown command "export" for "stripe". And just running export GODEBUG=netdns=1 after loggin in with stripe does nothing.

And yes, the 192... entry is within the file you mentioned:

#
# This file is automatically generated.
#
domain speedport.ip
nameserver fe80::1
nameserver 192.168.2.1
JackEllis commented 5 years ago

For anyone arriving on this ticket running into an issue similar to:

Failed to POST event to local endpoint, error = Post https://xxxxxxxxx/stripe/webhook: dial tcp: lookup xxxxxxx.test on x.x.x.x.x.: no such host

As @ob-stripe suggested above, you might need to set it manually. I use Laravel Valet locally and it wasn't playing nicely, so I added an entry manually to /etc/hosts and it now works perfectly.

Incredible work @ob-stripe, @tomer-stripe and team. What a fantastic (and truly desired) project.

lukepearce commented 4 years ago

As @ob-stripe suggested above, you might need to set it manually. I use Laravel Valet locally and it wasn't playing nicely, so I added an entry manually to /etc/hosts and it now works perfectly.

What did your entry to hosts look like?

JackEllis commented 4 years ago

@lukepearce I did something like:

127.0.0.1 mysite.test

lukepearce commented 4 years ago

Hmmm, I still get lookup site.test on 192.168.0.1:53: no such host - That's with 192.168.0.1 and 192.168.0.1:53 and 127.0.0.1 in my hosts file. Is it still working for you?

JackEllis commented 4 years ago

@lukepearce What's the :53 about? Is that meant to be a colon? And it could be some internal firewall stuff going on regarding port 53...

lukepearce commented 4 years ago

@JackEllis I'm not sure, I'm using a standard valet set up as far as I'm aware.

JuanRangel commented 4 years ago

@lukepearce Any luck with this? I'm running laravel valet and adding the domain to the hosts file does not work.

MrMooky commented 4 years ago

I tried a few things over time, but nothing worked for me neither. Still getting errors. Basic Laravel (5.8) Valet setup. "Good" to see I'm not the only one with this problem.

When updating the hosts file as mentioned by @JackEllis, my installation goes offline.

Screenshot 2019-10-25 at 10 02 41
ob-stripe commented 4 years ago

Hey everyone. I think this is ultimately a DNS setup issue and not something that the Stripe CLI can solve, but as a possible workaround, you could try this:

$ stripe listen --forward-to http://127.0.0.1 --headers "Host: http://mysite.test"

This way, the CLI will no longer need to resolve the domain name (because you're directly providing an IP address) but will still send the Host header (which might or might not be needed by Laravel's web server).

MrMooky commented 4 years ago

@ob-stripe This worked. 🎉 Thanks a lot! I had to change the IP with the one my system provided, though.

edalzell commented 4 years ago

I try the above and get this:

image

This is frustrating as valet is a very normal way to get Laravel sites up and running

ob-stripe commented 4 years ago

@edalzell This doesn't seem like it's the same issue. In the screenshot you posted, the requests are correctly sent to the web server running on localhost:80, and the server replies with a 404. Can you double-check that you've registered your webhook handler's route as POST /!/Charge/webhook?

edalzell commented 4 years ago

Yup, works when I do valet share and have the webhook registered properly.

It's really weird to me that stripe can't "find" charge.test. I can ping it just fine from the command line.

ob-stripe commented 4 years ago

@edalzell To be clear, these are 2 unrelated issues:

The latter is almost certainly an issue with your integration, not with the CLI.

The former is due to an annoying issue with Go itself (the programming language the CLI is written in), and only affects macOS users: https://github.com/golang/go/issues/12524. We could technically fix it today but it would require some major changes to our release pipeline which we're not willing to do at this time given that a simple workaround exists. Hopefully the issue will be fixed upstream at some point and then future releases of the CLI will no longer have this issue.

edalzell commented 4 years ago

ah OK thanks. I'll watch that issue in the hopes it's fixed.

chriso0710 commented 4 years ago

If I understand correctly, this issue with .test domains on OS X is still valid. I'm using a .test domain in local development (Ruby Sinatra app with puma-dev). The only solution that works for me currently is:

$ stripe listen --forward-to http://localhost:5000/stripe
ob-stripe commented 4 years ago

Just wanted to give a heads up that the latest version of the CLI (v1.3.12) should now be able to use .test and other local domains directly, without having to use the 127.0.0.1 workaround.

ianjamieson commented 3 years ago

I was experiencing this issue using localhost and docker, for example, my original command was:

docker run --rm -it stripe/stripe-cli listen --api-key KEY --load-from-webhooks-api --forward-to localhost:1337

And I was getting the error

 Failed to POST: Post http://127.0.0.1:1337/stripe/webhook: dial tcp 127.0.0.1:1337: connect: connection refused

To fix, I needed to change the networking mode to --network="host", so the full command:

docker run --network="host" --rm -it stripe/stripe-cli listen --api-key KEY --load-from-webhooks-api --forward-to localhost:1337
tillkruss commented 3 years ago

To clarify: When using Laravel Valet, adding 127.0.0.1 foobar.test to your /etc/hosts file will make this work:

stripe listen --forward-to https://foobar.test/stripe/webhook
benjamincrozat commented 2 years ago

To clarify: When using Laravel Valet, adding 127.0.0.1 foobar.test to your /etc/hosts file will make this work:

stripe listen --forward-to https://foobar.test/stripe/webhook

This is the way to go, thanks!

paulocentr commented 2 years ago

To clarify: When using Laravel Valet, adding 127.0.0.1 foobar.test to your /etc/hosts file will make this work:

stripe listen --forward-to https://foobar.test/stripe/webhook

JESUS christ i was stucked here thanks man haha

obione86 commented 2 years ago

For anyone arriving on this ticket running into an issue similar to:

Failed to POST event to local endpoint, error = Post https://xxxxxxxxx/stripe/webhook: dial tcp: lookup xxxxxxx.test on x.x.x.x.x.: no such host

As @ob-stripe suggested above, you might need to set it manually. I use Laravel Valet locally and it wasn't playing nicely, so I added an entry manually to /etc/hosts and it now works perfectly.

Incredible work @ob-stripe, @tomer-stripe and team. What a fantastic (and truly desired) project.

egbon Jack to the rescue!!! bro this laravel developer waka (journey) would have been a looong thing without all these nuggets you drop all over the internet. This has saved me another few hours today, one bottle of very chilled beer for you if we ever get to meet. Thanks dude.

timleland commented 2 years ago

All the tips helped me to get Stripe CLI working with Laravel Valet. I also ran into an SSL issue and had to add –skip-verify when running the CLI. I wrote a post that laid out all the steps. Hopefully, it will help others in the future.

How to use Stripe CLI with Laravel Valet: https://timleland.com/how-to-use-stripe-cli-with-laravel-valet/

LucyRa commented 1 year ago

@timleland I tried following your example but still have the same issue (400 failed to connect to remote host) - is this issue likely to have the same resolve across intel & m1 machines?

britotiagos commented 1 year ago

For those who arrive here from google trying stripe login and got a similar error to this thread. Error:

Your pairing code is: ..........
This pairing code verifies your authentication with Stripe.
Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?cliauth_Nizsf?secret=1111111111 
(^C to quit)Get "https://dashboard.stripe.com/stripecli/auth/cliauth_Nim0zsf?secret=1111111111": dial tcp: lookup dashboard.stripe.com on 192.168.0.1:53: no such host

What worked for me was removing: nameserver 192.168.0.1

from /etc/resolv.conf and adding google nameserver instead nameserver 8.8.8.8

jragusa-stripe commented 11 months ago

Meh, I wind up just getting... `listen tcp: lookup localhost on 8.8.8.8:53: no such host Where is the :53 coming from?

dualklip commented 7 months ago

I was experiencing this issue using localhost and docker, for example, my original command was:

docker run --rm -it stripe/stripe-cli listen --api-key KEY --load-from-webhooks-api --forward-to localhost:1337

And I was getting the error

 Failed to POST: Post http://127.0.0.1:1337/stripe/webhook: dial tcp 127.0.0.1:1337: connect: connection refused

To fix, I needed to change the networking mode to --network="host", so the full command:

docker run --network="host" --rm -it stripe/stripe-cli listen --api-key KEY --load-from-webhooks-api --forward-to localhost:1337

I have Laradock environment and this solution works for me. Thank you @ianjamieson