6 days ago
Our app consistently gets 'Premature close' when trying to fetch https://oauth2.googleapis.com/token from Railway. Same code works locally. Appears to be an outbound network connectivity issue from our environment to Google's servers. Can you check our project's firewall/network policies?
Invalid response body while trying to fetch https://oauth2.googleapis.com/token: Premature close
4 Replies
6 days ago
This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.
Status changed to Open Railway • 6 days ago
6 days ago
Hey! This is unrelated to the platform, how are you fetching the tokens? Is it a node project?
6 days ago
Hey - we're getting the same, started around 9:53am PT and is now consistently getting "premature close". Works locally as well.
6 days ago
Turned out to be related to this Node issue: https://github.com/nodejs/node/issues/63989
Pinning to the patched version in Railpack and redeploying fixed it:
{
"$schema": "https://schema.railpack.com",
"packages": {
"node": "22.23.1"}
}
6 days ago
The Premature close error usually means the connection was closed before Google finished sending the response. Since it works locally but fails on Railway, I'd check these in order:
Test from inside your Railway service
curl -v https://oauth2.googleapis.com/token
If this fails too, it points to a network or TLS issue.
Force IPv4
Sometimes IPv6 routing causes intermittent connection problems. If you're using Node.js, try forcing IPv4 (family: 4) or disable IPv6 temporarily and test again.
Disable HTTP/2
Some HTTP clients have issues with HTTP/2. Try using HTTP/1.1 and see if the error disappears.
Check your runtime
Make sure the same Node.js/Bun version and HTTP library are being used locally and on Railway.
If curl from inside the Railway container also fails, I'd ask Railway to check outbound connectivity to oauth2.googleapis.com. If curl succeeds but your application still fails, the problem is likely in the HTTP client or runtime rather than the Railway network.