17 hours ago
Project ID: [PASTE PROJECT ID HERE]
Plan: Hobby
Service: Node/Express app (single service + Postgres)
ISSUE
Since Jul 5 at ~10:42 AM CDT, every outbound HTTPS call from my service to
api.anthropic.com fails mid-response with ERR_STREAM_PREMATURE_CLOSE. The
connection opens and the request is accepted, but the stream drops before
the response completes. This happens on 100% of calls — it is constant,
not intermittent.
ERROR
API Error: Premature close undefined undefined
(originally ERR_STREAM_PREMATURE_CLOSE via @anthropic-ai/sdk before I
switched to streaming mode — same underlying drop either way)
Example occurrences from deploy logs (deployment 6ddbe5f4):
Jul 5 2026 at 17:59:27 API Error: Premature close undefined undefined
Jul 5 2026 at 18:00:57 API Error: Premature close undefined undefined
WHAT I'VE RULED OUT
-
My code — errors began at 10:42 AM CDT, before any commits that day.
Error predates all recent changes.
-
My Anthropic account/key — the identical call (same key, same SDK,
same model, same payload) succeeds instantly from my local machine
on a residential connection.
-
Payload size — fails identically on small and large request bodies.
-
Retries — maxRetries: 3 on the SDK client; all attempts fail.
-
Streaming vs non-streaming — switched messages.create to
messages.stream; same drop.
-
A bad host — forced a fresh redeploy (new container, deployment
6ddbe5f4); error persisted immediately on the new instance.
-
A bad region — changed the service region entirely and redeployed;
error persists identically in the second region.
Anthropic's status page shows all API systems operational throughout
this window.
SUMMARY
Same request: works from residential internet, fails from two different
Railway regions across multiple fresh deployments. Everything points to
the egress path between Railway and api.anthropic.com (or Railway egress
IPs being filtered/reset by Anthropic's edge).
I emailed team@railway.com on Jul 5 with these diagnostics and was
redirected here.
This is a production app whose core function is blocked by this. Happy
to provide deploy IDs, timestamps, or run any network diagnostics from
the container that would help.
Pinned Solution
17 hours ago
I have seen threads with this exact same issue, you have to update your node version to 24.18 or newer
2 Replies
17 hours ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 17 hours ago
17 hours ago
I have seen threads with this exact same issue, you have to update your node version to 24.18 or newer
Status changed to Solved brody • about 16 hours ago
3 hours ago
Resolved — posting the root cause for the record.
Root cause was the Anthropic SDK's bundled fetch implementation, not Railway's network. Appreciate the help getting here.
We isolated it layer by layer inside the production container via the Railway Console:
Raw https.request to api.anthropic.com → succeeded
Native fetch (globalThis.fetch) to api.anthropic.com → succeeded
Anthropic SDK (@anthropic-ai/sdk) making the same call → failed with "Premature close"
The SDK ships with its own fetch implementation rather than using Node's native one. Something in the request/response path changed around 10:42 AM CDT on July 5 that the SDK's bundled transport couldn't handle, while Node's native fetch handled it fine.
Fix: pass fetch: globalThis.fetch in the Anthropic client constructor to force the SDK to use Node's native fetch instead of its bundled version. One-line change, immediate resolution.
The Node version upgrade suggestion wasn't the fix in this case, but it helped rule that variable out quickly. Thanks again.
Status changed to Awaiting Conductor Response Railway • about 3 hours ago