2 months ago
My instance is not working properly like if I run my backend locally, I am getting response within few milli seconds but when deployed it's taking 3-4 mins. The same issue persists last night but at late night the issue was resolved but now again the response is taking too much time.
11 Replies
2 months ago
Hey!
Do you mind sharing more details? What type of workload are you running?
Status changed to Awaiting User Response Railway • 2 months ago
mahmoud-railway
Hey! Do you mind sharing more details? What type of workload are you running?
2 months ago
i am running a node js backend with 2 cron jobs with mongodb M10 cluster. The backend is working perfectly when i deployed it in render but in railway its not responding even after 30 mins of the request
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
Do you mind sharing more details? What errors/logs are you seeing?
Status changed to Awaiting User Response Railway • 2 months ago
mahmoud-railway
Do you mind sharing more details? What errors/logs are you seeing?
2 months ago
There are no errors in the logs there is just my cron job running and when i send a request to fetch its not responding back or taking too much time like 5 mins.
2025-12-28T06:47:59.830Z ::ffff:100.64.0.12 GET /api/v1/chat/history 200 1103425 - 1464.398 ms (morgan log)
its showing it responded in 1.4 seconds but i am getting response in like 2-3 mins
HTTP LOG:
requestId:"Ex2Hae9xQW2xguDL5nX1uw"
timestamp:"2025-12-28T13:29:29.369878956Z"
method:"GET"
path:"/api/v1/chat/history"
httpStatus:200
upstreamProto:"HTTP/1.1"
downstreamProto:"HTTP/1.1"
responseDetails:""
totalDuration:146890
clientUa:"PostmanRuntime/7.51.0"
upstreamRqDuration:146744
txBytes:1103425
rxBytes:457
edgeRegion:"europe-west4-drams3a"
upstreamErrors:""
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
Hi there
This sounds like a host/port binding issue, which commonly causes slow or unresponsive apps on Railway. On Railway, your Node.js server needs to bind to 0.0.0.0 (not localhost or 127.0.0.1) and use the PORT environment variable that we automatically inject. If you're using Express, that would look like:
const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0", function () {
// ...
});It seems the response times increased around Dec 26th, where I see there were new changes pushed and traffic spiked. Since Node.js is single-threaded, that would indicate heavy load. Make sure your domain's target port matches the port your application is actually listening on (you can find this in Service Settings).
One more thing: since you're connecting to MongoDB Atlas, verify that your Railway service's outbound IP isn't being blocked by MongoDB's network access rules. You may need to allow access from anywhere (0.0.0.0/0) or add Railway's IPs to your allowlist.
Best, The Railway Team
Status changed to Awaiting User Response Railway • 2 months ago
sarahkb125
Hi thereThis sounds like a host/port binding issue, which commonly causes slow or unresponsive apps on Railway. On Railway, your Node.js server needs to bind to 0.0.0.0 (not localhost or 127.0.0.1) and use the PORT environment variable that we automatically inject. If you're using Express, that would look like:const port = process.env.PORT || 3000; app.listen(port, "0.0.0.0", function () { // ... });It seems the response times increased around Dec 26th, where I see there were new changes pushed and traffic spiked. Since Node.js is single-threaded, that would indicate heavy load. Make sure your domain's target port matches the port your application is actually listening on (you can find this in Service Settings).One more thing: since you're connecting to MongoDB Atlas, verify that your Railway service's outbound IP isn't being blocked by MongoDB's network access rules. You may need to allow access from anywhere (0.0.0.0/0) or add Railway's IPs to your allowlist.Best, The Railway Team
2 months ago
There are no port issues, also my mongodb network access already had access from any where, I have deployed the same backend in render too there its working fine i dont know why its not working in railway.
I have done your suggested changes too, I have binded to 0.0.0.0 still having the same issue.
I've made new service for my jobs but still my api service is still giving delays upto 2-3 mins, the issue still persists
Status changed to Awaiting Railway Response Railway • 2 months ago
panchalparth471
There are no port issues, also my mongodb network access already had access from any where, I have deployed the same backend in render too there its working fine i dont know why its not working in railway.I have done your suggested changes too, I have binded to 0.0.0.0 still having the same issue.I've made new service for my jobs but still my api service is still giving delays upto 2-3 mins, the issue still persists
2 months ago
I have noticed its working perfectly right now, but in the morning (IST) it gives the same request's response in 3 mins but right now it gives response in under 3 seconds why ?
2 months ago
Which routes on your backend are making DB calls? I'm seeing a few under the "http logs" panel that take anywhere from 400ms to 2 minutes. Thats definitely not ideal but want to learn a bit more before jumping to a conclusion
noahd
Howdy! Where are you hosting your mongo cluster?
2 months ago
The MongoDB cluster is hosted on MongoDB Atlas in the AWS Mumbai (ap-south-1) region.
panchalparth471
The MongoDB cluster is hosted on MongoDB Atlas in the AWS Mumbai (ap-south-1) region.
2 months ago
/chat/history - Fetches chat history
/stories/personalized - Fetches Stories (Reels like thumbnail url, gif url, audio url, story text) but for personalized
/stories/community - Fetches Community Stories