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β€’10mo ago
Project ID: db634f71-f603-49d6-a5b1-73020aa17159
frostycucumber_65343
frostycucumber_65343β€’10mo ago
db634f71-f603-49d6-a5b1-73020aa17159 I apologize but I only see "service id" in the settings not the project id
Brody
Brodyβ€’10mo ago
show me the code that runs the server?
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Which part would you like me to paste here
Brody
Brodyβ€’10mo ago
the code that runs the server
frostycucumber_65343
frostycucumber_65343β€’10mo ago
you mean the build script?
Brody
Brodyβ€’10mo ago
no
frostycucumber_65343
frostycucumber_65343β€’10mo ago
like the entire server code?
Brody
Brodyβ€’10mo ago
no can you share the repo instead
frostycucumber_65343
frostycucumber_65343β€’10mo 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β€’10mo ago
put me in the repo brody192
frostycucumber_65343
frostycucumber_65343β€’10mo ago
ok gimmi sec i think github is down just keeps spinning when adding collaborator pls give me one min
frostycucumber_65343
frostycucumber_65343β€’10mo ago
oh damn now it seems to work adding added
Brody
Brodyβ€’10mo ago
delete the dist and ds store file from the repo, then add dist/ and .DS_Store to your .gitignore
frostycucumber_65343
frostycucumber_65343β€’10mo ago
I see ok one min thanks done let me check once yes i think I did it should i check deployement?
Brody
Brodyβ€’10mo ago
of course
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Ok this is ridiculus it works! How though!! Thanks allot
Brody
Brodyβ€’10mo 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β€’10mo 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β€’10mo 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β€’10mo ago
Thank you so much, let me find that link Done, thanks again, can I add you as a friend?
Brody
Brodyβ€’10mo ago
sure!
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Sorry i am new to discord just figuring it out
Brody
Brodyβ€’10mo ago
no worries and thanks for the trains πŸ™‚
frostycucumber_65343
frostycucumber_65343β€’10mo ago
haha sure thing! I guess friend reqs are not allowed
Brody
Brodyβ€’10mo 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β€’10mo 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β€’10mo ago
node dist/index.js would suffice, since railway would restart your deployment if it crashed
frostycucumber_65343
frostycucumber_65343β€’10mo ago
I see that sounds really great
Brody
Brodyβ€’10mo ago
lot a problems can arise from using pm2 or nodemon on railway in fact
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Oh I see
Brody
Brodyβ€’10mo ago
though I know those are two different things, you get my point lol
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Yeah no I get it
Brody
Brodyβ€’10mo ago
any more questions?
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Deploying the main project to see if it connects to wss πŸ˜„ not yet πŸ˜„
Brody
Brodyβ€’10mo ago
where is the websocket server hosted?
frostycucumber_65343
frostycucumber_65343β€’10mo ago
railway? guess i didn't get the question
Brody
Brodyβ€’10mo ago
oh I thought the deployment on railway is connecting to a different websocket server
frostycucumber_65343
frostycucumber_65343β€’10mo ago
Oh no, i have a next js project that connects to the socket server
Brody
Brodyβ€’10mo ago
ah I see, we'll let me know if you have any troubles
frostycucumber_65343
frostycucumber_65343β€’10mo ago
thank you will do
Want results from more Discord servers?
Add your server
More Posts