What port does railway expose for node apps?
I have a very simple express app, I have it in a monorepo just to test some stuff, it builds fine, it starts fine, but I get the "application failed to respond" error when going to it on the provided domain
I'm logging all traffic, and I can see that I'm not getting any when navigating to the domain
I've tested the build locally, and it builds and starts just fine
Any ideas?
Solution:Jump to solution
Each application will be assigned a random port number. Unless you specify. Your code above sets the port variable. You would want to do something like
const PORT = process.env.PORT || 3000;
Then when you deploy, it will use the railway provided port, which will automatically display in the selection when you add a domain...9 Replies
Project ID:
bd3d866d-5a9a-4ddc-8e35-c05a24db4b74
bd3d866d-5a9a-4ddc-8e35-c05a24db4b74
Here are the deploy logs which show it's running
Thinking it might be a port mismatch or something
Solution
Each application will be assigned a random port number. Unless you specify. Your code above sets the port variable. You would want to do something like
const PORT = process.env.PORT || 3000;
Then when you deploy, it will use the railway provided port, which will automatically display in the selection when you add a domainAh I see
If you want to continue using 3000 as your port, you must set a PORT environment variable as 3000 in your service
Makes sense, thanks
No problem