R
Railway4mo 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
Fragly4mo ago
where are you defining your PORT variable?
Gero
Gero4mo ago
I need a PORT variable?
Brody
Brody4mo 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
Gero4mo ago
Do I need a PORT in here?
No description
Brody
Brody4mo ago
please see the last message I sent
Gero
Gero4mo ago
like this am I listening correctly?
No description
Brody
Brody4mo ago
I believe fragly has asked you to show him where that variable is defined in your code
Gero
Gero4mo ago
It's defined here in my server. Is that correct?
No description
Brody
Brody4mo ago
yeah that variable looks like what it should be set to, you're good there. what do your deployment logs say?
Gero
Gero4mo ago
deployment logs look good don't they?
No description
No description
No description
Brody
Brody4mo ago
lots of information is being cut off in these screenshots, instead please use this https://bookmarklets.up.railway.app/log-downloader/
Gero
Gero4mo ago
this is my error
No description
Brody
Brody4mo ago
yep I saw the screenshots in your first post message
Gero
Gero4mo ago
Brody
Brody4mo ago
you're exiting in the app.listen callback
Gero
Gero4mo ago
yes is this not good?
Brody
Brody4mo ago
if your app exits, how is it supposed to handle requests, when it's not running!?
Gero
Gero4mo ago
it doesn't continue to run when it exits. so I get rid of process.exit();
Brody
Brody4mo ago
read that sentence out loud please ..yes
Gero
Gero4mo ago
thanks man I will try building again now it actually fails to built. It timed out.
Brody
Brody4mo ago
this looks like a separate issue, this time an issue with railway
Gero
Gero4mo ago
should I try again later or is there some fix to this?
Brody
Brody4mo ago
try again in 10 minutes
Gero
Gero4mo ago
nope I think it gets stuck after building nextBuild and it we need to exit.
Brody
Brody4mo ago
isnt next the frontend?
Gero
Gero4mo ago
next is ssr so I guess not. But anyway it now builds again since I added back in process.exit();
Brody
Brody4mo ago
something being SSR doesn't mean it's not a frontend. you should be running next and payload in separate railway services
Gero
Gero4mo 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
Brody4mo ago
correct
Gero
Gero4mo 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
Brody4mo ago
yes, you are exiting, you will need to split the backend and frontend apart
Gero
Gero4mo ago
Now I got 404 error cannot get though. Any idea why?
No description
Brody
Brody4mo ago
have you split your backend and frontend into two separate railway services?
Gero
Gero4mo ago
no not yet but the payload cms is working
Brody
Brody4mo ago
please split them apart