25 days ago
Hello,
I’m experiencing an issue with one of my Railway services, and after several checks it seems related to how HTTP routing is handled for the service.
Context
I have a Node.js service deployed on Railway.
The service:
starts correctly,
listens on the port provided by Railway (process.env.PORT),
and the logs show:
Code
[INFO] Starting HTTP server…
[INFO] Server listening on port XXXX
In Settings → Networking → Public Networking, Railway displays a public domain for this service (I’m not including it here for privacy reasons).
Issue
When I send an HTTP POST request to this public domain, I consistently receive:
Code
Cannot POST /
This appears to be Railway’s default HTML response, which suggests that the request is not being routed to my Node.js server, even though the server is running and listening correctly.
What I have already verified
My Express server exposes POST / at the root path.
The service starts without errors.
The server uses the correct port (process.env.PORT).
The domain shown under “Public Networking” is the one I’m calling.
I do not see an “Expose service to the internet” option, which suggests the service is already public.
I also do not see a “Service Type” option (Web / Worker) in the service settings.
Hypothesis
It seems that the public domain is generated correctly, but HTTP traffic may not be routed to the container, even though the server is running.
Question
Could you please verify whether this service is correctly configured as a Web Service on your infrastructure, and whether HTTP routing is properly attached to the container?
Thank you in advance for your help.
Best regards,
Philippe
Pinned Solution
23 days ago
"Cannot POST /" is express talking, not railway, which actually means routing IS working and your request reached the app. it just means you dont have a route handler for POST /. so its app-level: either you defined app.get('/') but are sending a POST, or your route path doesnt match, or some middleware is swallowing it. also fyi theres no "web/worker service type" toggle in railways UI, that doesnt exist, all you need is your express app listening on process.env.PORT and a domain generated under public networking (which you have). so add the matching route, e.g. app.post('/', handler), and youre good.
4 Replies
25 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 25 days ago
25 days ago
"Cannot POST /" is not Railway's response. It's Express's own default 404 for an unmatched route. The request is reaching your Node.js server just fine.
This means Railway routing is actually working correctly. The problem is in the app itself.
Most likely causes:
You're calling app.get('/') or app.use('/') instead of app.post('/')
The app.post('/') call happens after app.listen(), or inside a callback that hasn't fired yet
A middleware (like express.Router()) is mounted at / and swallows the request before the POST handler sees it
You're actually hitting a different server instance
25 days ago
Hello,
I’m having an issue with one of my Railway services: MCP-Server-Agent_ts.
This service runs an HTTP Node.js (Express) server that correctly listens on process.env.PORT, and the logs confirm that it starts without any errors. However, any HTTP request sent to the public domain consistently returns:
Code
Cannot POST /
After investigation, it appears that HTTP traffic is not being routed to my container, which suggests that the service is not configured as a Web Service.
The problem is that I do not have the “Service Type: Web / Worker” option in the Railway UI, even though your documentation indicates it should be available. I therefore cannot enable Web mode myself.
Could you please:
check the current service type of MCP-Server-Agent_ts,
force it to be set as a Web Service,
or enable HTTP routing for this service?
Without this, my Express server never receives incoming requests.
Thank you very much for your assistance.
Best regards,
Philippe
Attachments
25 days ago
There's no "Service Type" setting, the AI you're using is hallucinating.
Make sure your express server is listening to PORT and a HTTP Proxy generated under the "Public Networking" section.
23 days ago
"Cannot POST /" is express talking, not railway, which actually means routing IS working and your request reached the app. it just means you dont have a route handler for POST /. so its app-level: either you defined app.get('/') but are sending a POST, or your route path doesnt match, or some middleware is swallowing it. also fyi theres no "web/worker service type" toggle in railways UI, that doesnt exist, all you need is your express app listening on process.env.PORT and a domain generated under public networking (which you have). so add the matching route, e.g. app.post('/', handler), and youre good.
Status changed to Solved passos • 17 days ago

