Railway webhooks in production: duplicates, ordering, retries and timeouts
This guide covers the problems you meet when Railway sends project webhooks to your endpoint, and how to handle each one. These are the deployment status and alert events Railway sends about a project. To receive other services' webhooks in an app you host on Railway, see how to receive and replay external webhooks in Railway.
What Railway sends is on the Railway webhooks overview and Railway webhook events, and how to check your custom header is on Verify Railway webhooks.
At a glance
| Problem | What to do | With Event Gateway |
|---|---|---|
| Timeouts | Return within 30 seconds; process in a background job | Answers Railway at once, then queues the event for your service |
| Duplicates | Make handlers idempotent, and don't drop repeated crash events | Drops repeats on the fields you choose |
| Ordering | Read the deployment's current state from the public API | Stores each event it receives, so you can inspect and replay them |
| Retries | Keep the endpoint up, and reconcile after an outage | Your downtime doesn't count against your Railway URL |
| Choosing events | Route on the type prefix and filter by environment | Filters and routes on any field in the body |
| Testing | Click Test Webhook, then trigger a real deployment | Forwards to localhost and replays past requests |
| Other limits | Use a long random custom header over HTTPS | Compares the header you name with the value you enter |
Railway's 30-second timeout
Return a response within 30 seconds, then do the work in a background job. Each delivery attempt has a 30-second timeout, and a timeout counts as a failure.
Why it happens: A handler that opens an incident, calls a paging tool and runs smoke tests before it responds can run past the limit. Railway then retries the event, and the failure counts towards the threshold that pauses your URL.
Fix it in your handler:
- Check the header, store the body and return
200. See why to process webhooks asynchronously. - Do the work in a worker, outside the request.
With Event Gateway: Hookdeck answers Railway as soon as an event arrives, then delivers it to your service with a delivery timeout you choose.
Duplicate Railway events
Railway doesn't document duplicate deliveries, but a retry can repeat an event you've already handled. Make every handler safe to run twice.
Why it happens: If your handler finishes but its response is slow or lost, Railway treats the attempt as failed and retries it. The documented body has no event ID to deduplicate on. Some repeats are also real: Railway's alerts guide treats repeated crash events for the same service as a signal worth paging on, so don't discard them all.
Fix it in your handler:
- Key each event on
resource.deployment.id,typeandtimestamp. Railway doesn't say whether a retry keeps the sametimestamp, so log a few retries before you rely on it. See our guide to webhook idempotency. - Make the action itself repeatable, for example by updating an open incident for that deployment rather than opening a new one.
- Count
Deployment.crashedevents for a service over a short window, rather than discarding repeats. - Capture a real alert before you choose a key for alerts, because Railway publishes no alert payload.
With Event Gateway: Hookdeck deduplicates requests before they reach your endpoint, using the fields you choose.
Out-of-order and missing Railway events
Railway doesn't guarantee delivery or order. Its docs say to treat a webhook as a prompt to act, and to reconcile against the public API when you need certainty.
Why it happens: Delivery is best-effort, so a later state can arrive before an earlier one and an event can fail to arrive at all.
Fix it in your handler:
- When the current state matters, read the deployment from the public API using
resource.deployment.idrather than trusting the arrival order. - If you store state from events alone, compare
timestampwith the last one you stored before you overwrite anything. - Read the state from
type. Railway's example pairsDeployment.failedwith"status": "SUCCESS"indetails, so the two may not agree.
With Event Gateway: Hookdeck stores every event it receives, so you can inspect the history and replay any of it. It can't recover an event Railway never sent, so keep your API check.
Railway retries and paused URLs
Railway retries a failed delivery up to 3 times with exponential backoff. If a URL reaches 100 failures within a 6-hour window, Railway stops sending to it for 24 hours.
Why it happens: Any 2xx or 3xx response counts as success, and any other status, a timeout or a connection error counts as a failure. Railway doesn't publish the backoff intervals or say whether each attempt counts separately towards the 100. It doesn't say whether events from the 24-hour pause are sent later, and it documents no way to resend one, so assume they're gone. It also documents no notice when a URL is paused.
A 3xx counts as delivered, and Railway doesn't say it follows redirects, so a URL that redirects can look healthy while your handler receives nothing.
Fix it in your handler and project:
- Keep the endpoint thin and highly available, and respond before doing any work.
- Alert on errors from your own endpoint, so you notice well before the threshold.
- Point the webhook at the final URL, and confirm it answers
2xxdirectly. - If the receiver runs on Railway, deploy it in its own project, so an outage in the project you monitor can't take your alerting down with it.
- After an outage, read recent deployments from the public API to find what you missed.
With Event Gateway: Hookdeck accepts each event as it arrives and stores it, so failures in your service don't count against Railway's threshold. It delivers to your service with retries on a schedule you control, and you can replay anything that failed.
Choosing and routing Railway events
Choose only the events you act on, route on the part of type before the dot, and filter by environment.
Why it happens: Railway describes categories rather than a list: deployment status changes, volume usage alerts and CPU/RAM monitor alerts. Its webhook docs name only Deployment.failed. Its own agent skill adds Deployment.crashed and Deployment.oom_killed as defaults for its create-webhook tool.
The deployment reference lists states such as Building and Active, but not how each one is written in type, so don't build names from it. Alert names aren't documented at all.
A webhook also fires across every environment in the project, including ephemeral ones. CPU/RAM monitors need the Pro plan and are set per environment, so a webhook only sees alerts from the environments you've set up.
Fix it in your handler:
- Split
typeon the first dot, and handle the states you know. - Return
200for anything else and log it, so you learn the real names from your own traffic. - Check
resource.environment.nameandisEphemeralbefore you page anyone. Through the MCP tools,includePreviewEnvironmentsturns off preview environments for a webhook.
With Event Gateway: Hookdeck filters can route on type, severity or any resource field, for example sending only production Deployment.failed events to your paging tool. Hookdeck also logs each full body, which shows you the type values your project really sends.
Testing Railway webhooks locally
Click Test Webhook after every header change, then trigger a real deployment to confirm the whole path.
Why it matters: Railway's servers can't reach localhost. Test Webhook sends a sample with your custom headers and shows the status your endpoint answered, with a 10-second timeout rather than 30. Railway's pages disagree about where it comes from: the webhooks page says Railway sends it, and the alerts guide says your browser does, so CORS can make a working endpoint look like a failure. A real deployment settles it either way.
How to test it:
- Run
hookdeck listen 3000 railwayand use the URL it prints as the webhook URL. - Add your custom header and click Test Webhook.
- Trigger a deployment and check your endpoint receives it. Railway publishes no alert payload, so you need a real alert to see one.
With Event Gateway: The Hookdeck CLI forwards requests to localhost, and you can replay past requests without deploying again.
Other Railway limits
A custom header isn't a signature. Railway doesn't sign payloads, and the timestamp in the body isn't signed. Your custom header proves the sender knows the secret, but it doesn't cover the body, and a captured request can be replayed. Use a long random value over HTTPS, and confirm the deployment's state through the API before you act on anything consequential, such as a rollback.
A secret in the URL is a weaker fallback. Railway says a hard-to-guess path or query parameter works if your receiver can't read headers, but URLs tend to end up in access logs.
Discord and Slack URLs get a different body. Railway rewrites the payload for those destinations, so what they receive isn't the JSON documented for your own URL.
No source IPs are published. Railway's webhooks page names no addresses to allow, so authenticate with the header rather than a firewall rule.
With Event Gateway: Create a source with the Railway type, then enter your custom header's name as API Key Header and its whole value as API Key, including any Bearer prefix. A request that fails the check is recorded as failed verification and never reaches your service. The source checks a header only, so don't use Railway's URL fallback with it.
Get started with Hookdeck for free and handle Railway webhooks reliably in minutes.
Keep an outage on your side from pausing your Railway webhook.
Event Gateway checks your custom header, accepts each event as it arrives, queues it and retries to your service on your schedule, so your downtime doesn't count as failures against your Railway URL.