R
Railway9mo ago
Gero

Unable to access my project. ERROR 503

hi so I published this Next.js project which uses an Express server but I am having issues when trying to open the URL. I get 503 although the build is completed successfully, does anyone know why this might happen?
No description
No description
No description
No description
36 Replies
Fragly
Fragly9mo ago
where are you defining your PORT variable?
Gero
Gero9mo ago
I need a PORT variable?
Brody
Brody9mo ago
your code needs to listen on the PORT environment variable, you don't need to set one yourself though, it's automatically assigned
Gero
Gero9mo ago
Do I need a PORT in here?
No description
Brody
Brody9mo ago
please see the last message I sent
Gero
Gero9mo ago
like this am I listening correctly?
No description
Brody
Brody9mo ago
I believe fragly has asked you to show him where that variable is defined in your code
Gero
Gero9mo ago
It's defined here in my server. Is that correct?
No description
Brody
Brody9mo ago
yeah that variable looks like what it should be set to, you're good there. what do your deployment logs say?
Gero
Gero9mo ago
deployment logs look good don't they?
No description
No description
No description
Brody
Brody9mo ago
lots of information is being cut off in these screenshots, instead please use this https://bookmarklets.up.railway.app/log-downloader/
Gero
Gero9mo ago
this is my error
No description
Brody
Brody9mo ago
yep I saw the screenshots in your first post message
Gero
Gero9mo ago
Brody
Brody9mo ago
you're exiting in the app.listen callback
Gero
Gero9mo ago
yes is this not good?
Brody
Brody9mo ago
if your app exits, how is it supposed to handle requests, when it's not running!?
Gero
Gero9mo ago
it doesn't continue to run when it exits. so I get rid of process.exit();
Brody
Brody9mo ago
read that sentence out loud please ..yes
Gero
Gero9mo ago
thanks man I will try building again now it actually fails to built. It timed out.
Brody
Brody9mo ago
this looks like a separate issue, this time an issue with railway
Gero
Gero9mo ago
should I try again later or is there some fix to this?
Brody
Brody9mo ago
try again in 10 minutes
Gero
Gero9mo ago
nope I think it gets stuck after building nextBuild and it we need to exit.
Brody
Brody9mo ago
isnt next the frontend?
Gero
Gero9mo ago
next is ssr so I guess not. But anyway it now builds again since I added back in process.exit();
Brody
Brody9mo ago
something being SSR doesn't mean it's not a frontend. you should be running next and payload in separate railway services
Gero
Gero9mo ago
Ok so my server as it is does not work as a backend/front end like this all in one? I should do an express server for payload only as one service and another one for next is that correct?
Brody
Brody9mo ago
correct
Gero
Gero9mo ago
this is not MERN stack project so I kind of hoped to have all in one next project. It should be possible. is this 503 error related to not splitting the front end from the backend?
Brody
Brody9mo ago
yes, you are exiting, you will need to split the backend and frontend apart
Gero
Gero9mo ago
Now I got 404 error cannot get though. Any idea why?
No description
Brody
Brody9mo ago
have you split your backend and frontend into two separate railway services?
Gero
Gero9mo ago
no not yet but the payload cms is working
Brody
Brody9mo ago
please split them apart
Want results from more Discord servers?
Add your server