stripe-cli icon indicating copy to clipboard operation
stripe-cli copied to clipboard

"Failed to connect to Stripe" when running "stripe listen"

Open peterb0yd opened this issue 2 years ago • 19 comments

Issue

After following the instructions to run stripe webhooks locally, I'm not able to get past "Getting ready...". I'm not behind a company firewall or proxy.

instructions I followed: https://stripe.com/docs/stripe-cli

Expected Behavior

It should start listening for events that get triggered via stripe trigger payment_intent.succeeded as mentioned in the instructions

Steps to reproduce

  1. Download stripe-cli via homebrew link
  2. brew install stripe/stripe-cli/stripe
  3. login in terminal via stripe login
  4. run local webhook express server file (named server.js) using the example code via node server.js
  5. run stripe listen command using stripe listen --forward-to localhost:4242/webhook (I added --log-level=debug to show the issue that's happening)

Traceback

stripe listen --forward-to localhost:8080/webhooks/stripe --log-level=debug 

⣾ Getting ready... [Wed, 13 Apr 2022 15:35:03 PDT] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣯ Getting ready... [Wed, 13 Apr 2022 15:35:14 PDT] DEBUG stripeauth.Client.Authorize: Got successful response from Stripe default_version=2020-08-27 display_connect_filter_warning=false latest_version=2020-08-27 reconnect_delay=248 websocket_authorized_feature=webhook-payloads websocket_id=cliws_{5086}_O2nivhb4Ef3xOeEg8lMlCMPl0uOY3AloXNXYOsJ8Rp3Pf1QnHW websocket_url=wss://stripe-cli.stripe.com/subscribe/acct_1KUgMLJYMOMTx4nT
[Wed, 13 Apr 2022 15:35:14 PDT] DEBUG websocket.client.Run: Attempting to connect to Stripe
[Wed, 13 Apr 2022 15:35:14 PDT] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripe-cli.stripe.com/subscribe/acct_1KUgMLJYMOMTx4nT?websocket_feature=webhook-payloads
⣽ Getting ready... [Wed, 13 Apr 2022 15:35:24 PDT] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: i/o timeout message=
[Wed, 13 Apr 2022 15:35:24 PDT] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
⢿ Getting ready... [Wed, 13 Apr 2022 15:35:34 PDT] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripe-cli.stripe.com/subscribe/acct_1KUgMLJYMOMTx4nT?websocket_feature=webhook-payloads
⣟ Getting ready... ^C[Wed, 13 Apr 2022 15:35:36 PDT] DEBUG proxy.Proxy.Run: Ctrl+C received, cleaning up...
[Wed, 13 Apr 2022 15:35:36 PDT] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: operation was canceled message=
[Wed, 13 Apr 2022 15:35:36 PDT] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
[Wed, 13 Apr 2022 15:35:36 PDT] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripe-cli.stripe.com/subscribe/acct_1KUgMLJYMOMTx4nT?websocket_feature=webhook-payloads
[Wed, 13 Apr 2022 15:35:36 PDT] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: operation was canceled message=

Environment

macOS - m1 chip

peterb0yd avatar Apr 13 '22 22:04 peterb0yd

Hey @peterb0yd! This is interesting, not sure I've seen this before. Just tested on my side and everything's working for me locally so nothing seems to be out of order.

What version of the CLI are you running? Also, did the stripe trigger command work for you? (Similarly does stripe customers create succeed?)

tomer-stripe avatar Apr 13 '22 22:04 tomer-stripe

Hey thanks for the quick reply.

I'm using stripe version 1.8.6

stripe trigger does work.

stripe customers create seemed to work:

> stripe customers create
{
  "id": "cus_LVFi6Bp8KAxqG1",
  "object": "customer",
  "address": null,
  "balance": 0,
  "created": 1649890957,
  "currency": null,
  "default_source": null,
  "delinquent": false,
  "description": null,
  "discount": null,
  "email": null,
  "invoice_prefix": "AAD3EF22",
  "invoice_settings": {
    "custom_fields": null,
    "default_payment_method": null,
    "footer": null
  },
  "livemode": false,
  "metadata": {
  },
  "name": null,
  "next_invoice_sequence": 1,
  "phone": null,
  "preferred_locales": [

  ],
  "shipping": null,
  "tax_exempt": "none",
  "test_clock": null
}

peterb0yd avatar Apr 13 '22 23:04 peterb0yd

Hmmm so no issues connecting with Stripe itself. I've not used these before but I'm wondering if they work for you?

  • https://websocketstest.com/
  • https://www.piesocket.com/websocket-tester

I'm trying to see if something on your side is interrupting the connection or of it's something on us. Also could you try running with --no-wss and see if that works?

tomer-stripe avatar Apr 13 '22 23:04 tomer-stripe

Hmm, websockets do work:

Screen Shot 2022-04-13 at 4 29 32 PM Screen Shot 2022-04-13 at 4 29 58 PM
> stripe listen --no-wss --log-level=debug
⣟ Checking for new versions... [Wed, 13 Apr 2022 16:28:52 PDT] DEBUG Error while sending telemetry data: Post "https://r.stripe.com/0": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

⣾ Getting ready... [Wed, 13 Apr 2022 16:28:59 PDT] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣯ Getting ready... [Wed, 13 Apr 2022 16:29:10 PDT] DEBUG stripeauth.Client.Authorize: Got successful response from Stripe default_version=2020-08-27 display_connect_filter_warning=false latest_version=2020-08-27 reconnect_delay=231 websocket_authorized_feature=webhook-payloads websocket_id=cliws_{22078}_yiPyo7BCOuLNHq9nZIL0I3dMrKVneV4gW4o3F6afTSaiQeStKA websocket_url=wss://stripe-cli.stripe.com/subscribe/acct_1KUgMLJYMOMTx4nT
[Wed, 13 Apr 2022 16:29:10 PDT] DEBUG websocket.client.Run: Attempting to connect to Stripe
[Wed, 13 Apr 2022 16:29:10 PDT] DEBUG websocket.Client.connect: Dialing websocket url=ws://stripe-cli.stripe.com/subscribe/acct_1KUgMLJYMOMTx4nT?websocket_feature=webhook-payloads
⡿ Getting ready... [Wed, 13 Apr 2022 16:29:13 PDT] DEBUG Error while sending telemetry data: Post "https://r.stripe.com/0": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

⣽ Getting ready... [Wed, 13 Apr 2022 16:29:20 PDT] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: i/o timeout message=

Same issue unfortunately ☹️

peterb0yd avatar Apr 13 '22 23:04 peterb0yd

hey so I tried these same steps on my mac mini at home without any issues. I have a feeling I may just need to run brew upgrade on my macbook and then re-install the stripe-cli. I'll give a shot tomorrow.

peterb0yd avatar Apr 14 '22 04:04 peterb0yd

Huh, weird! Alright, let me know if that works

tomer-stripe avatar Apr 14 '22 16:04 tomer-stripe

hey @peterb0yd - just wanted to check in and see if brew upgrade ended up solving things for you? Let me know, and if not we can try and troubleshoot this further!

charliecruzan-stripe avatar Apr 25 '22 15:04 charliecruzan-stripe

Thanks for following up.

It was kinda weird. It only caused issues on my work WiFi and only after the first attempt. When I switch Wifi from 2.4ghz to 5ghz or vice-versa, it works on the first try. If I disconnect and retry, it fails with the above error so I have to switch networks and re-run the command.

It wasn't a big deal however cuz I can only test payments on production. We're connecting bank accounts with Plaid so we can't login to a Plaid dev bank account using Stripe in dev cuz Plaid always uses real bank accounts in dev. It's a pain but w/e.

peterb0yd avatar Apr 25 '22 23:04 peterb0yd

Ah, I see, that is super weird though that it'll work when you switch networks...not sure what would cause that 🤔 especially since you said there's no company firewall

In the meantime it doesn't look like there's something actionable for us to do right now, so I'll close this issue, but feel free to follow up here with us if you learn more or if the problem gets worse/more annoying!

charliecruzan-stripe avatar Apr 26 '22 15:04 charliecruzan-stripe

Just experienced exactly the same issue. On my WiFi the results of debugging gives me:

⡿ Getting ready... [Wed, 27 Apr 2022 13:45:16 IST] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: i/o timeout message= [Wed, 27 Apr 2022 13:45:16 IST] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...

Yet, on a 3G/4G connection I seem to have no issues. Also using macOS - m1 chip.

Followed this video on setting up.

UPDATE: I realised I was logged into another account which did not have it's email confirmed by Stripe yet. After I switched back to my verified account, I was able to work from my WiFi again through the CLI. (not sure if this helps)

RobSchilderr avatar Apr 27 '22 12:04 RobSchilderr

I'm having same problem. Command stripe listen --forward-connect-to ... gets stuck at ⣻ Getting ready... screen. However same command seems to work before I upgraded stripe CLI last week.

Stripe version:

➜ stripe --version
stripe version 1.12.3

I'm using Mac M1.

PS. I also tried reinstalling CLI but no luck.

EDIT:

After adding --log-level=debug in the command, it gives following output:

➜ stripe listen --forward-to localhost:4040/webhooks/stripe --log-level=debug
[Thu, 29 Sep 2022 12:42:47 IST] DEBUG config.Config.InitConfig: Using profiles file path=/Users/ishan/.config/stripe/config.toml
⣟ Checking for new versions...[Thu, 29 Sep 2022 12:42:50 IST] DEBUG Error while sending telemetry data: Post "https://r.stripe.com/0": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

⣾ Getting ready...[Thu, 29 Sep 2022 12:42:57 IST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣾ Getting ready...[Thu, 29 Sep 2022 12:43:07 IST] DEBUG stripeauth.Client.Authorize: Got successful response from Stripe default_version=2020-08-27 display_connect_filter_warning=false latest_version=2022-08-01 reconnect_delay=214 websocket_authorized_feature=webhook-payloads websocket_id=cliws_{5569}_y1WfsqZCtG3fgYflRZpUyhJbKnheBN3HI5ugBZUOQh0NBTjiUX websocket_url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1
[Thu, 29 Sep 2022 12:43:07 IST] DEBUG websocket.client.Run: Attempting to connect to Stripe
[Thu, 29 Sep 2022 12:43:07 IST] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1?websocket_feature=webhook-payloads
⣯ Getting ready...[Thu, 29 Sep 2022 12:43:10 IST] DEBUG Error while sending telemetry data: Post "https://r.stripe.com/0": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

⢿ Getting ready...[Thu, 29 Sep 2022 12:43:17 IST] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: lookup stripecli-ws-nw.stripe.com: i/o timeout message=
[Thu, 29 Sep 2022 12:43:17 IST] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
⣯ Getting ready...[Thu, 29 Sep 2022 12:43:27 IST] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1?websocket_feature=webhook-payloads
⣽ Getting ready...[Thu, 29 Sep 2022 12:43:38 IST] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: lookup stripecli-ws-nw.stripe.com: i/o timeout message=
[Thu, 29 Sep 2022 12:43:38 IST] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
⡿ Getting ready...[Thu, 29 Sep 2022 12:43:48 IST] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1?websocket_feature=webhook-payloads
⣷ Getting ready...[Thu, 29 Sep 2022 12:43:58 IST] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: lookup stripecli-ws-nw.stripe.com: i/o timeout message=
[Thu, 29 Sep 2022 12:43:58 IST] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
⣻ Getting ready...[Thu, 29 Sep 2022 12:44:07 IST] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1?websocket_feature=webhook-payloads
⣟ Getting ready...[Thu, 29 Sep 2022 12:44:17 IST] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: lookup stripecli-ws-nw.stripe.com: i/o timeout message=
[Thu, 29 Sep 2022 12:44:17 IST] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
⣽ Getting ready...[Thu, 29 Sep 2022 12:44:27 IST] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1?websocket_feature=webhook-payloads
⣽ Getting ready...^C[Thu, 29 Sep 2022 12:44:34 IST] DEBUG proxy.Proxy.Run: Ctrl+C received, cleaning up...
[Thu, 29 Sep 2022 12:44:34 IST] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: lookup stripecli-ws-nw.stripe.com: operation was canceled message=
[Thu, 29 Sep 2022 12:44:34 IST] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
[Thu, 29 Sep 2022 12:44:34 IST] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/acct_1HbSzHF9NVx519I1?websocket_feature=webhook-payloads

ishan-eventrac avatar Sep 29 '22 06:09 ishan-eventrac

It works if I use VPN! ¯\(ツ)

ishan-eventrac avatar Oct 03 '22 11:10 ishan-eventrac

I just upgraded and ran into this problem. It use to work a few weeks ago on same network/setup.

Tried disabling telemetry via STRIPE_CLI_TELEMETRY_OPTOUT=1 but still get tripecli-ws-nw.stripe.com: i/o timeout

epelc avatar Oct 15 '22 19:10 epelc

Having the same issue on M1 chip x(

Susros avatar Nov 30 '22 14:11 Susros

Oh! It works after I cleared my network DNS.

Susros avatar Nov 30 '22 14:11 Susros

I just experienced this issue on my M1 Mac and burned about 3 hours troubleshooting it 😅

Same as a lot of the previous comments here: websockets worked fine in general, no connection issues to other services. --no-wss did not help, clearing my network DNS did not help, adding new DNS servers to my WiFi router did not help...BUT I was able to get stripe listen up and running by adding Cloudflare's DNS server (1.1.1.1) directly to my DNS settings for my WiFi connection in System Preferences > Network > WiFi > Advanced > DNS.

There seem to be several people experiencing this issue - found the fix that finally worked in recent comments on an old closed issue #359 .

mngarwood avatar Dec 07 '22 18:12 mngarwood

I just experienced this issue on my M1 Mac and burned about 3 hours troubleshooting it 😅

Same as a lot of the previous comments here: websockets worked fine in general, no connection issues to other services. --no-wss did not help, clearing my network DNS did not help, adding new DNS servers to my WiFi router did not help...BUT I was able to get stripe listen up and running by adding Cloudflare's DNS server (1.1.1.1) directly to my DNS settings for my WiFi connection in System Preferences > Network > WiFi > Advanced > DNS.

There seem to be several people experiencing this issue - found the fix that finally worked in recent comments on an old closed issue #359 .

You saved my day, thank you!

wass08 avatar Mar 13 '23 06:03 wass08

Facing the same issue on Ubuntu with the stripe-cli 1.18.0. Following the suggestion by @wass08 changed the /etc/resolv.conf nameserver to 8.8.8.8 Stripe cli was then able to connect, login and receive the ping/pong messages

mreddimasi avatar Oct 25 '23 09:10 mreddimasi

just refer to [(https://www.windowscentral.com/how-change-your-pcs-dns-settings-windows-10)] this article your problem will be immediately solved, it's just a matter of networking issues, nothing else to panic for...

SwapnilSonker avatar Jan 12 '24 18:01 SwapnilSonker