Lorixen.
EN

Webhooks failing because your endpoint redirects? Fix the URL

Short answer: Many webhook senders don't follow redirects. If the URL you registered answers with a 301, 302, 307 or 308 instead of a 2xx success, the delivery is recorded as failed, even though the page loads fine in your browser, which follows redirects silently. Common causes are registering http:// when the site forces https://, the bare domain when the site redirects to www, or a missing or extra trailing slash. Find the final URL the request ends up at, register that exact URL with the provider, and resend the failed events.

Why a redirect counts as a failure

A webhook is an HTTP POST from another service, such as a payment provider, shop platform or form tool, to a URL on your site. The sender expects a success status in the 2xx range. Stripe's documentation is explicit: it considers redirect responses to webhook requests as failures, and tells you to set the endpoint to the URL the redirect resolves to.

There's a good technical reason too. MDN notes that when many clients receive a 301 in response to a POST, they repeat the request as a GET, which drops the webhook's body. A 308 is meant to keep the method and body, but you can't rely on every sender following any redirect at all. The safest assumption is that the registered URL must answer directly.

The usual suspects

Most redirect failures come from one of these:

  • HTTP to HTTPS. The endpoint was registered as http:// and your server forces HTTPS.
  • Bare domain to www (or the reverse). example.co.uk redirects to www.example.co.uk.
  • Trailing slash rules. Your framework or CMS adds or removes a slash at the end of URLs, so /webhooks/payments becomes /webhooks/payments/.
  • Language or region prefixes. A site redirects all paths to /en/... based on settings.
  • A login or maintenance page. A redirect to a sign-in screen or "coming soon" page catches the webhook path.
  • A moved site. After a redesign or domain change, old paths redirect to new ones, including the webhook route.

Find the final URL

You can see what a sender sees by making a request without following redirects. With curl, a POST request using -i to show response headers reveals the status code and any Location header. If you get a 3xx, follow the Location value and test again until you get a non-redirect answer. That final URL is the one to register.

Also check the provider's delivery log. Most show the response status and sometimes the response headers for each attempt, which tells you immediately whether you're seeing a redirect, an error or a timeout.

Fix it in the right place

You have two options, and often both are worth doing:

Register the exact final URL with the provider. This is the quickest fix and the one Stripe recommends. Include the correct scheme, host, path and trailing slash exactly as your server serves it.

Stop your site redirecting the webhook path. Exclude webhook routes from HTTPS-to-www rewrites if they're handled at a different host, from trailing-slash normalisation, from language redirects and from maintenance-mode rules. Webhook routes should also skip login checks and CSRF protection designed for browser forms, while still verifying the provider's signature.

Don't forget edge and hosting rules

Redirects don't only come from your application. A CDN, a hosting control panel or a load balancer can add its own rules, such as forcing HTTPS, adding www or redirecting old paths after a migration. If your code looks right but the delivery log still shows a 3xx, check those layers too, then send a test event from the provider's dashboard to confirm a 2xx response.

Resend what failed

Once the URL is fixed, recover the events you missed. Providers usually retry automatically for a while. Stripe, for example, says it retries live-mode deliveries for up to three days with exponential backoff, and fewer times in a sandbox. If the retry window has passed, use the provider's dashboard to resend events, or fetch recent events through its API and process them.

Check for side effects: if your system creates orders or sends emails from webhooks, make sure handling the same event twice doesn't create duplicates.

Prevent it next time

  • Treat webhook URLs as configuration. Keep a list of every registered endpoint, with the provider, the event types and the exact URL.
  • Check webhooks after any site move. Domain changes, HTTPS switches, CMS migrations and new redirect rules should include a webhook test.
  • Respond quickly with 2xx. Stripe advises returning a successful status before any complex logic that might time out, then doing the heavy work afterwards.
  • Monitor failures. Many providers email after repeated failures, but make sure those messages reach someone. A simple alert when your system hasn't received a payment event for a few hours on a busy day catches silent breakage.

An illustrative example

An online homeware shop in Brighton moves to a new platform and switches its domain to www. Payment confirmations stop updating orders, though customers are charged. The payment provider's log shows each delivery receiving a 301 to the www address with a trailing slash. The developer registers the exact final URL, excludes the webhook path from the platform's slash rule, resends the missed events from the dashboard, and checks that no orders were duplicated. They add a webhook test to the shop's launch checklist.

FAQ

Why does the URL work when I open it in a browser?

Browsers follow redirects automatically and use GET. Webhooks are POST requests that often don't follow redirects.

Will a 308 redirect fix it?

Not reliably. Some senders treat any 3xx as a failure. Register the final URL instead.

Can I use the same endpoint for test and live webhooks?

You can, but separate URLs or clear handling for each mode makes problems easier to spot.

What if the provider shows a 403 instead?

That's usually a firewall, bot protection or authentication rule, not a redirect. Check those rules for the webhook path.

If your payment or shop webhooks are failing and orders aren't updating, tell us which services send them.

Sources

WhatsAppBook a call