Node server error but deployment worked
jordey92
HOBBYOP

2 years ago

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

I'm not really sure what to look for to find out what is wrong.

4 Replies

jordey92
HOBBYOP

2 years ago

1c3e4a4f-c6fe-4419-bb90-a9fda1ff6517


2 years ago

You need to listen on the port that railway provides

in your case

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


jordey92
HOBBYOP

2 years ago

I will give that a try, thank you!


jordey92
HOBBYOP

2 years ago

That was it, thank you!


Loading...