Intermittent Stripe timeouts to host — Caddy server issue?

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:

VPS running Ubuntu 18.04

d. My complete Caddyfile or JSON config: {

        handle /api* {
                reverse_proxy localhost:4000

        handle {
                root * /var/www/html
                try_files {path} /index.html

3. The problem I’m having:

I’m setting up Stripe webhooks for the first time. I’ve made hundreds of test requests and I’ve had an error rate of around 90%. It’s unpredictable as to why the failures occur.

The failure responses on the Stripe dashboard are either:

Timed out connecting to remote host


Failed to connect to remote host

My webhook (I’ve simplified it for testing). Roughly 10% of the time, I get a 200 response with {received: true}:

expressRouter.route('/hooks').post( async (req, res) => {

  const event = req.body;


  // Handle the event
  switch (event.type) {
    case 'payment_intent.succeeded':
      const paymentIntent =;
      // Then define and call a method to handle the successful payment intent.
      // handlePaymentIntentSucceeded(paymentIntent);
    case 'payment_method.attached':
      const paymentMethod =;
      // Then define and call a method to handle the successful attachment of a PaymentMethod.
      // handlePaymentMethodAttached(paymentMethod);
    // ... handle other event types
      console.log(`Unhandled event type ${event.type}`);

  // Return a response to acknowledge receipt of the event
  res.json({received: true});

I have tried these two ways of defining the hook, and also with and without async:

expressRouter.route('/hooks').post( async (req, res) => {
// and"/hooks", async (req, res) => {

I’ve been in contact with Stripe support and have tried all their suggestions.
They left me with the following possibilities:

It possible there is a slow network involved or some other issue with routing.

The host provider may need to allow Stripe’s delivery IP address, too, FYI
they may be getting blocked before reaching your server

I have added Stripe’s IPs to iptables, eg:

iptables -I INPUT -p tcp -s -j ACCEPT

I’m running my Hostinger VPS server with Caddy on Ubuntu 18.04. Could this be an issue with my server set up? Any advice is greatly appreciated.

4. Error messages and/or full log output:

How do I output logs?

I seem to have it working.

I installed ngrok via apt (ngrok - download)

Then followed this: How to test webhooks locally with ngrok - Twilio Tip #6 - YouTube, and set up ngrok to forward to localhost:4000.

I just sent a load of requests and they were all successful. I’m not sure quite how this works / why I needed it, but I’m very happy to have it working. If anyone can explain why it wasn’t working without this, please let me know!


Please upgrade to v2.4.6!

Is your DNS properly configured for your domain, to point to the correct IP of your VPS?

Are you running Caddy as a systemd service? If so, see here:

You can also enable the debug global option by adding this at the top of your Caddyfile, which will show you more detail in your logs:

1 Like

Yeah; I’m guessing some misconfiguration with DNS, routing table, firewall, kernel, or other OS-level system settings.

This topic was automatically closed after 30 days. New replies are no longer allowed.