a day ago
My Node.js bot (discord.js v14) is unable to establish a Gateway WebSocket connection. The process starts normally and gets to the debug log line "Preparing to connect to the gateway...", then hangs indefinitely — no success, no error, no timeout from the library itself.
What I've already ruled out:
- Token is valid: GET /api/v10/users/@me with the bot token returns 200 OK.
- Not a session-start rate limit: GET /api/v10/gateway/bot shows remaining: 1000 of 1000.
- Not a Discord outage: discordstatus.com shows Gateway and API fully operational.
- Not a Railway platform-wide outage: status.railway.com shows all regions operational.
- Not a code regression: tried dns.setDefaultResultOrder('ipv4first') to rule out IPv6 routing issues — no change.
- Not isolated to one container: created a brand-new service (same repo, same region) and it hits the exact same hang.
It only affects the persistent WebSocket Gateway connection — plain HTTPS/REST calls to Discord's API work fine from the same environment.
Project ID: bbf95ed1-79bf-4cb9-8fd1-fa410dbf0478
Affected services: 7f9788f5-49d1-4a4b-a269-aa8d476efa29 (bot-contas-pais) and 18de05f6-7c6f-4fe7-8e2b-18abf70bc05e (mindful-respect, new test service)
Region: US West (California, USA)
Could you check if there's an outbound networking issue (firewall, proxy, or routing) affecting persistent WebSocket connections to wss://gateway.discord.gg from this account's US West deployments?
Pinned Solution
a day ago
Just select US East, replacing US West.
It will ask you to apply changes.
6 Replies
a day ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 1 day ago
a day ago
Hey, does it prints "Fetched Gateway Information" in the logs?
Can you try redeploying on US East (or any other region) just for testing purposes?
medim
Hey, does it prints `"Fetched Gateway Information"` in the logs? Can you try redeploying on `US East` (or any other region) just for testing purposes?
a day ago
No, "Fetched Gateway Information" does not appear — it hangs right after "Preparing to connect to the gateway...", before that line would show. I just ran the exact same code locally (outside Railway) and there "Fetched Gateway Information" does appear normally, followed by the full handshake completing successfully.
On trying US East: I'm on the Hobby plan, and the region selector shows "Multi-region replicas are only available on the Pro plan" when I try to change it. Does that block switching my single deployment to a different region on Hobby, or just adding multiple regions at once? If it's possible on Hobby, happy to try it.
karenww
No, "Fetched Gateway Information" does not appear — it hangs right after "Preparing to connect to the gateway...", before that line would show. I just ran the exact same code locally (outside Railway) and there "Fetched Gateway Information" does appear normally, followed by the full handshake completing successfully. On trying US East: I'm on the Hobby plan, and the region selector shows "Multi-region replicas are only available on the Pro plan" when I try to change it. Does that block switching my single deployment to a different region on Hobby, or just adding multiple regions at once? If it's possible on Hobby, happy to try it.
a day ago
It is possible on Hobby! That's just for you replicas, do you have any?
medim
It is possible on Hobby! That's just for you replicas, do you have any?
a day ago
Yes, I only have 1 replica. The UI just showed that "Pro plan" message right next to the region dropdown, which made me think switching was blocked entirely, but if it's actually fine with just 1 replica, how do I perform the switch? Should I just select "US East" in that same dropdown (replacing US West), or is there a different place to do it?
karenww
Yes, I only have 1 replica. The UI just showed that "Pro plan" message right next to the region dropdown, which made me think switching was blocked entirely, but if it's actually fine with just 1 replica, how do I perform the switch? Should I just select "US East" in that same dropdown (replacing US West), or is there a different place to do it?
a day ago
Just select US East, replacing US West.
It will ask you to apply changes.
medim
Just select US East, replacing US West. It will ask you to apply changes.
5 hours ago
Thank you so much, switching to US East fixed it completely! Really appreciate the quick help.
Status changed to Solved 0x5b62656e5d • about 5 hours ago