Anyone who has recently deployed a nodejs server on railway willing to help?

My server runs fine locally, however when deployed its not listening to the requests. I put in the run command as "node dist/index.js" which works perfectly fine in the local machine. I am also listening to the recommended port "process.env.PORT" which railway provides as an environment variable and ip of '0.0.0.0' as mentioned in the docs. Not sure what am I doing wrong here.
42 Replies
Percy
Percy•11mo ago
Project ID: db634f71-f603-49d6-a5b1-73020aa17159
frostycucumber_65343
frostycucumber_65343•11mo ago
db634f71-f603-49d6-a5b1-73020aa17159 I apologize but I only see "service id" in the settings not the project id
Brody
Brody•11mo ago
show me the code that runs the server?
frostycucumber_65343
frostycucumber_65343•11mo ago
Which part would you like me to paste here
Brody
Brody•11mo ago
the code that runs the server
frostycucumber_65343
frostycucumber_65343•11mo ago
you mean the build script?
Brody
Brody•11mo ago
no
frostycucumber_65343
frostycucumber_65343•11mo ago
like the entire server code?
Brody
Brody•11mo ago
no can you share the repo instead
frostycucumber_65343
frostycucumber_65343•11mo ago
not sure if its ok to ask but can I pay you for an hour of your time and add you to the repo? I am undergoing a SOC2 audit right now and its a private repo its just 300 lines of code
Brody
Brody•11mo ago
put me in the repo brody192
frostycucumber_65343
frostycucumber_65343•11mo ago
ok gimmi sec i think github is down just keeps spinning when adding collaborator pls give me one min
frostycucumber_65343
frostycucumber_65343•11mo ago
oh damn now it seems to work adding added
Brody
Brody•11mo ago
delete the dist and ds store file from the repo, then add dist/ and .DS_Store to your .gitignore
frostycucumber_65343
frostycucumber_65343•11mo ago
I see ok one min thanks done let me check once yes i think I did it should i check deployement?
Brody
Brody•11mo ago
of course
frostycucumber_65343
frostycucumber_65343•11mo ago
Ok this is ridiculus it works! How though!! Thanks allot
Brody
Brody•11mo ago
while you may have been using process.env.PORT in the typescript code, the built index file in dist was old and outdated, still listening on a fixed port
frostycucumber_65343
frostycucumber_65343•11mo ago
Wow, I would have never guessed is there a way to tip you good sir? do you also offer consulting? thank you again
Brody
Brody•11mo ago
if you absolutely insist, there's a buymeacoffee in my bio, do not feel obligated to send anything, I never expect anything in return
frostycucumber_65343
frostycucumber_65343•11mo ago
Thank you so much, let me find that link Done, thanks again, can I add you as a friend?
Brody
Brody•11mo ago
sure!
frostycucumber_65343
frostycucumber_65343•11mo ago
Sorry i am new to discord just figuring it out
Brody
Brody•11mo ago
no worries and thanks for the trains 🙂
frostycucumber_65343
frostycucumber_65343•11mo ago
haha sure thing! I guess friend reqs are not allowed
Brody
Brody•11mo ago
they should be, but I have no clue you're always welcome to open more help threads me or the other conductors will be around
frostycucumber_65343
frostycucumber_65343•11mo ago
Thank you that sounds amazing So on ec2 I used to run these jobs using pm2, is it neccessary to do that in this case as well or would node dist/index suffice? Just making sure the server wouldn't stop
Brody
Brody•11mo ago
node dist/index.js would suffice, since railway would restart your deployment if it crashed
frostycucumber_65343
frostycucumber_65343•11mo ago
I see that sounds really great
Brody
Brody•11mo ago
lot a problems can arise from using pm2 or nodemon on railway in fact
frostycucumber_65343
frostycucumber_65343•11mo ago
Oh I see
Brody
Brody•11mo ago
though I know those are two different things, you get my point lol
frostycucumber_65343
frostycucumber_65343•11mo ago
Yeah no I get it
Brody
Brody•11mo ago
any more questions?
frostycucumber_65343
frostycucumber_65343•11mo ago
Deploying the main project to see if it connects to wss 😄 not yet 😄
Brody
Brody•11mo ago
where is the websocket server hosted?
frostycucumber_65343
frostycucumber_65343•11mo ago
railway? guess i didn't get the question
Brody
Brody•11mo ago
oh I thought the deployment on railway is connecting to a different websocket server
frostycucumber_65343
frostycucumber_65343•11mo ago
Oh no, i have a next js project that connects to the socket server
Brody
Brody•11mo ago
ah I see, we'll let me know if you have any troubles
frostycucumber_65343
frostycucumber_65343•11mo ago
thank you will do
Want results from more Discord servers?
Add your server
More Posts