stripe/stripe-cli

POST request getting refused from the Stripe CLI

Opened this issue · 2 comments

The more information we have the easier it is for us to help. Feel free to remove any sections that might not apply

Issue

When attempting to trigger payment_intent.succeeded in the Stripe CLI, the following error occurs:
image
After reading related discussions, including PR #621, and testing all suggested solutions, the issue persists. The error seems related to the CLI failing to connect to the localhost endpoint.

Steps Taken

  1. Networking Suggestions:
    • Used 127.0.0.1 directly in web servers and instructed Stripe CLI to listen on 127.0.0.1.
    • Tried localhost with Stripe CLI set to listen on [::1] (IPv6 address).
  2. Command Modifications:
    • Explicitly added https:// in the Stripe CLI listen command, e.g., stripe listen --forward-to https://[::1]:3000/api/payment.
  3. Endpoint Verification:
    • Verified server endpoints and local listeners for correctness.
  4. Postman Request Test:
    • Sent a POST request from Postman to the endpoint and received a 200 OK response.

Expected Behavior

When triggering payment_intent.succeeded, the CLI should forward the event data to http://localhost:3000/api/payment and return a response.

Steps to reproduce

  1. spun the docker container following the reference https://docs.stripe.com/cli/docker
  2. also did the necessary port mapping to expose localhost.
  3. SSH into the container.
  4. stripe login
  5. triggered stripe trigger payment_intent.succeeded
  6. got the error

Traceback

Share any debug output that was given by the CLI

Environment

  • OS: Windows
  • Environment: Docker Container

Additional Context

I'm relatively new to using Stripe’s CLI, though I’ve covered most basics. I've tried to resolve the issue by troubleshooting various methods and configurations, but I still seem to be missing something critical. Any additional guidance would be greatly appreciated!

Hey @ank-it07, I was having some issues with this as well but saw this.

The solution is to use host.docker.internal:3000/ instead of localhost:300, or at least this worked for me.

Thanks for sharing @StevenKhuu27, It worked for me too! Appreciate it.