Application failed to respond
rick002
HOBBYOP

2 years ago

I configured the start command for a service by running an application in Angular, but unfortunately railway keeps telling me that the service failed to respond.

Solved

26 Replies

2 years ago

it's very likely you are trying to run a development server.

is this angular 16 or 17?


rick002
HOBBYOP

2 years ago

Angular 17


2 years ago

client-side rendered, or server-side rendered?


rick002
HOBBYOP

2 years ago

Client-side rendered


2 years ago

take a look at this template https://github.com/railwayapp-templates/angular-starter

remove any start or build commands you may have set in the service settings, then copy the nixpacks.toml and Caddyfile from this repo into your project.


rick002
HOBBYOP

2 years ago

I'm sorry, I made a mistake, it's angular 15.

I'm managing multiple versions in my local machine, and for somehow, the project seems to be generated with angular 15.


rick002
HOBBYOP

2 years ago

Thanks for sharing the repo, let me check.


2 years ago

hmm, I only have examples for angular 14 CSR, 16 CSR, 17 CSR, and 17 SSR.

https://github.com/brody192/angular-14-crud-example

so give the nixpack.toml and Caddyfiles from this repo a try instead, as 14 is likely far closer to 15 than my 17 example is.


rick002
HOBBYOP

2 years ago

Is ok, I have intentions of develop this project with angular 17 SSR, so I'm taking the necessary measures.


2 years ago

for Angular 17 SSR there is this example https://github.com/brody192/angular-starter-ssr

and the info on what needs to change can be found here https://github.com/brody192/angular-starter-ssr#user-content--what-was-changed-from-the-default-angular-17-server-side-rendered-example


rick002
HOBBYOP

2 years ago

Hi Brody, I followed the steps described in this section, https://github.com/brody192/angular-starter-ssr#user-content--what-was-changed-from-the-default-angular-17-server-side-rendered-example, but now I'm facing another issue:

Error: Cannot find module '/app/dist/x-gossip-ui/server/main.js'

It seems the build command is not running automatically, any advice?


2 years ago

as long as you have a build script it will be ran unless you have set something somewhere else, for me to be able to offer you the best help it would be great if I could see your repo.


rick002
HOBBYOP

2 years ago

Well I just fixed the issue I just shared before, I didn't set the build & start commands properly in my Build and Deploy railway configurations.

Here it is the Github repo. I'm testing in dev environment at the moment.

https://github.com/rick002/x-gossip-ui


rick002
HOBBYOP

2 years ago


2 years ago

looks like this is setup to do SSR? or at least serve the app from the inbuilt server, in that case the nixpacks.toml and Caddyfile aren't applicable since I was under the impression that this all was CSR.

what are you current build and start commands you have set in the railway service settings?


rick002
HOBBYOP

2 years ago

Build -> npm run build:ssr
Deploy -> npm start


2 years ago

npm run build:ssr looks like it builds and runs the server, you likely want to use npm run build aka the default railway would be using if left unset. start script looks fine though.


rick002
HOBBYOP

2 years ago

Oh rai, checking…


rick002
HOBBYOP

2 years ago

Now I'm getting the following -> Error: Cannot find module '/app/dist/x-gossip-ui/server/main.js'


2 years ago

my bad, you do indeed want npm run build:ssr as the build command, and npm run start as the start command


Status changed to Solved Railway about 2 years ago


rick002
HOBBYOP

2 years ago

Yep, now the web page is responding.

https://x-gossip-ui-dev.up.railway.app/

Tell me, is it any difference between npm run start and npm start in the context of a railway deployment?

Because in the end, it seems to be the only difference.


2 years ago

theres no difference in any context.


rick002
HOBBYOP

2 years ago

Then why it was not working properly with this configuration?

Build -> npm run build:ssr Deploy -> npm start


2 years ago

I just deployed your code with npm run build:ssr as the build command, and npm run start as the start command, it works.
changed the start command to npm start and it still works, so the issue was some other misconfiguration, I am not sure what though.


rick002
HOBBYOP

2 years ago

I don't know either, the only explanation is that I put the correct configurations but I assumed that it didn't work without having restarted the deployment and I didn't even notice it.

Thanks Brody.

Is it ok if we exchange our telegram contacts? I would like to get to know you better and learn a lot more from you.


2 years ago

happy to help!

I don't think we need to exchange information, if you have questions about railway or deploying something on railway you can always open another thread and myself or another community member will help!


Loading...