R
Railway7mo ago
jordan

Node server error but deployment worked

Hey, I'm learning a bit about web sockets and followed a tutorial and I wanted to deploy it to test how easy deploying would be as I want to build a proper app in future. Locally, it works fine running node server.js, but when I deployed it to railway, it errors when I go to the URL created with "Application failed to respond". In the deployment logs, it shows as successful and I am not sure what I have done wrong:
> node server.js

Listening on: http://localhost:8080
> node server.js

Listening on: http://localhost:8080
I'm not really sure what to look for to find out what is wrong.
Solution:
You need to listen on the port that railway provides https://docs.railway.app/guides/fixing-common-errors in your case ```js...
Jump to solution
4 Replies
Percy
Percy7mo ago
Project ID: 1c3e4a4f-c6fe-4419-bb90-a9fda1ff6517
jordan
jordan7mo ago
1c3e4a4f-c6fe-4419-bb90-a9fda1ff6517
Solution
Fragly
Fragly7mo ago
You need to listen on the port that railway provides https://docs.railway.app/guides/fixing-common-errors in your case
const port = process.env.PORT || 8080
const port = process.env.PORT || 8080
this will listen on the port railway provides and if that port is not given, it'll default to 8080
jordan
jordan7mo ago
I will give that a try, thank you! That was it, thank you!
Want results from more Discord servers?
Add your server