Application failed to respond
I am using monorepo to deploy my app. So the nest js (back) is deployed successfully and works. The front is also deployed successfully, but when I try to open it, I am getting app failed to respond: 503. How can I fix this?
98 Replies
Project ID:
2db87ff7-665b-4dd6-b79c-b558b72d44f7
project/2db87ff7-665b-4dd6-b79c-b558b72d44f7
I tried to add host in start command, but still same:
does your app listen on the same port as the PORT environment variable?
if you can't pick that from the env, check what port it actually starts on an set PORT to that number
where can I check it?
next should log that in deploy log when it's starting
do you mean this?
yeah, your port here is 4200
I'm reading next docs right not and it seems that you'd need to pass port as a flag
like this:
put the same port into env and it should work
I'm just not sure if railway will unwrap env variable like gitlab does, if so,
-p $PORT
would also workso where exactly should I put this? Could you please provide step by step?
yeah, sure
this is an api server but the logic is the same
so my varName is "start" and val: "next start -p 8090" ?
or you mean I need to pass PORT: 4200?
this variable needs to be set in the env
here
and then you start your server with -p 4200
just to make sure it always uses the same port
oh I misread it again. it's not next, it's nest
But I have problem not with server, not the backend, only front has issues the angular app
and you're using angular dev server in prod ???
the back works ok
yes
let's just start with adding
PORT=4200
to the frontend's envI'll try, give me a moment, thank you
still same
can you check if it still starts on the same port?
never actually worked with angular tbh
well I've seen some dev servers refuse to serve anything outside of localhost, maybe it's the case
do you absolutely need to use DEV server?
what else can I use? what do u mean?
build it for prod?
doesn't it work that way?
I'm sorry, can you explain what should I change in package.json?
build:client
will, well, build the app for the production use, but after that you'd need to tell railway to pick that up
lemme check the docks real quick
I'm assuming the build produces a bunch of html, css and js files
can you run build locally and show me what does it produce?sure
right, and the directory appears to be
dist/apps/client
is that correct?+
ok, trying to make static server work, I'll be back in a few minutes
I found a similar project of mine, testing with it
ok, I'll wait, thank you
add this dockerfile to the directory from which you deploy the frontend
the custom start command can also be removed
the idea here is that it copies all the build output to the container and starts nginx
oh and set the PORT to 80
that's the default setting
nginx is a web server in this context
but now both failes: back and front:
Just removed start command from front, waiting for deploy
also error
oh
is service root directory set for both services?
https://docs.railway.app/guides/monorepo
a dockerfile in frontend should not affect backend
that's the idea
I put dockerfile to the whole nx project
yeah, this isn't gonna work
should I put the docker only to apps/client?
what's the project structure?
probably you can just do that
do client and server have their own
package.json
s?
I'm just thinking of a way to separate them without breaking anything
this is after moving docker to client:
damn my brain really needs to adapt to github deployments ๐
I forgot to add build step
does the server deploy tho?
yes, but still same issue
and i did not removed the start commands
Why my server is running well, but the angular front can't work normally, this is so weird
idk why is it running actually, but with the frontend it's kinda expected
you either need to have a node server (not dev) or to use nginx/some other web server
ok, I think I have a dockerfile which would actually work but we still need to figure out how to only trigger the frontend
to trigger only a front we need to use start commands for sure i think
I'd say that the project structure needs to be adjusted
but for now can we try just making the frontend run?
but this is main structure made by nx
the new dockerfile
I hope it will work
try placing it in project root
backend will fail for sure
but frontend should come to life
build command is not needed with the dockerfile
same issue and deploy success bug give errors:
naaah it's not an error
it should actually work now
did u set PORT to 80?
oh wait, I removed port
I mean I see the same red console, it's just a bug
let me check with port 80
nah, still the same(
wait, works
yey
ohhh, now it works, but my back is not deployed ๐
well, at least not you know that it's possible ๐
idk really what to actually do next
I'd try to separate them into different directories somehow
but this just change my problem from front to back) anyways thx for your try
so that railway won't even touch the other part
maybe we can pass some variables? back and front and then use it in setting files?
like PORT: 80 but for which part of app to use
can you show me the backend error log?
I don't have any variables in server, and also I have build and start commands set in
the thing is that as the dockerfile is placed in the root, it is used for the both services and it's not gonna work
it will work for sure if you could somehow split them and give each it's own dockerfile or build command or whatever
is it ok when I refresh my front page it returns:
but when I start it first it works
oh that's a config issue
with nginx. it even was described here
the config
where should I put it?
apps/client?
right next to dockerfile
I'm trying to make it work in my test app
ohh, oke
btw config did not solve refresh issue
it's not linked yet
and it's broken ๐คฃ
seems to work now ๐
should I also put variable port 80 to my back?
back build successfully, but not working at all
oh wait, it also crashed. not success)
sorry but I don't think I can do anything here to make railway see the difference between them
except for actually converting project to a monorepo, where frontend and backend are in different folders and have 2 separate package.jsons
how can I do that?
but nx is also monorepot thing
My project is monorepo
Nx
Nx: Smart Monorepos ยท Fast CI
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
btw the config file is fixing issue now ๐
idk really I've never worked with this one and generally I'm not a fan of so called build systems
you know more about it than I do for sure
anyway thank you for your try))
I will wait, maybe someone can help me with this one. Thanks
@madhdsua I almost fixed it)
I renamed dockerfile to dockerfile.front, and using docker file only in front as variablName
now back works and front also. But front has some issues
Interesting
when I click create acc:
but if I run locally and click creat acc, works fine
prob need more config fiddling
yeeeeah it is
this is front deploy:
now it does not even want to run at all, I mean front
yeah I see it
same with mine xD
honestly I got no idea about this errors
I have. it returns wrong content-type header
I thing I have it under control
Solution
just added a line that included proper types
now it's good
still same
it may take a few minutes to propagate
is this space will not cause an issue?
nah it's not python
ohh, ok)
can u give me the fronted url real quick?
imma curl it
try clearing browser's cache
I see all correct headers now
almost works, cleared a cache, but now when I go to users page for example same error
weird...
and what's going on in the network tab?
dark magic I guess
u tried reloading page with Ctrl+F5, right?
+
how does it even do that ๐
ohhh oke, in incognito mode it works great, maybe this is my app auth.guard issue
Thanks a lot my mate)) I hope it will work in future. Now it works great, thanks mate)
you're welcome
I'd appreciate it if you mark this issue as solved
this thing