Container starts and stops 3 seconds later

crinklepackage
HOBBY

9 months ago

I have a Node.js/Express backend service deployed on Railway that's exhibiting strange behavior. The container starts successfully, establishes Redis connections, but then shuts down within 3-4 seconds.

Here are the logs:

`Starting Container

yarn run v1.22.22

$ node dist/index.js

Inside startServer function...

Server is listening...

Attempting Redis connection...

Redis client created successfully

Server and Redis initialization complete

Stopping Container`

The service needs to stay running to handle API requests and process a Bull queue for background jobs. Everything initializes correctly, but something is causing a premature shutdown. Any ideas on what could cause a container to exit cleanly right after successful startup?

1 Replies

9 months ago

Hello,

I see that you are trying to run two app in parallel inside the same service, perhaps a frontend and backend?

Services are designed to run only one app.

Instead, please have two Railway services, one for each app you want to run, and then have specific start commands set in the service settings of each service to start only one app or the other.

Best,
Brody