Container fails with SIGTERM on deployment (/app path error)
xeone59
HOBBYOP

8 months ago

Hi team, I'm encountering a recurring issue when deploying my Node.js backend on Railway.

When I trigger a deployment, the container fails with the following logs:
npm error path /app

npm error command failed

npm error signal SIGTERM

npm error command sh -c node src/server.js

npm error A complete log of this run can be found in: /root/.npm/_logs/...

My project is structured with src/server.js as the entry point, and my package.json has:
"scripts": {

"start": "node src/server.js"

}

I suspect the issue may be related to either:

  • Railway not recognizing the working directory correctly (e.g., it's looking for /app),

  • Or the wrong Start Command or Root Directory setting in the Railway project config.

What I’ve tried:

  • Ensured src/server.js exists and works locally (npm start runs fine).

  • Set the Start Command to npm start.

  • Tried setting Root Directory in Railway to / and to backend/, but no luck.

Project
Comet (please select it from the dropdown)

Urgency
High – blocking production deployment

Visibility
You may check the "Private" toggle if your logs contain sensitive data.
{ "severity": "error", "timestamp": "2025-05-25T19:47:12.048158555Z", "message": "npm error path /app", "tags": { "deploymentId": "a5820c69-9b6c-4150-97d3-610a90299b6a", "deploymentInstanceId": "98fa93a1-e33a-459e-af94-c238478e99ab", "environmentId": "a03c8446-0c6c-403e-bfa4-8128d0c1fea6", "pluginId": null, "projectId": "3617c28d-eeb3-48e2-943a-f0ba817dd991", "serviceId": "19e56be9-ce22-4868-98f6-9a36bb83cb26", "snapshotId": null }, "attributes": { "level": "error" } }

$10 Bounty

5 Replies

medim
MODERATOR

8 months ago

Can you try setting your start command as node src/server.js instead of running npm start?
You can also do a ls && node src/server.js so we can check dir structure.


psycholalia
HOBBY

8 months ago

Yeah, this is happening to me too. I tried setting the start command like how @medim suggested & the dir structure is:

README.md
node_modules
package-lock.json
package.json
railway.json
src

which seems legit. Looks like the container spins up successfully & after a minute or so throws these errors & shuts down.


neorilas
FREE

5 months ago

I have the same problem, but my project is just starting in index.js

I have another one deployed and is working fine, but this is gettin the error

npm error path /app

npm error command failed

npm error signal SIGTERM

npm error command sh -c node index.js

Anyone solved it? I tried to put the PORT as an ENVIRONMENT var, but it's not working


vinithkarthik
FREE

4 months ago

i am also facing this issue
Stopping Container

npm error path /app

npm error command failed

npm error signal SIGTERM

npm error command sh -c node index.js

npm error A complete log of this run can be found in: /root/.npm/_logs/2025-10-22T11_31_51_810Z-debug-0.log

deployment is success, but contianer stopping after this


yeeet
PRO

4 months ago

did you set your node server binds to 0.0.0.0:$PORT. you can read railway docs here as they explain it a bit more.

since you also have a subfolder, ie /src/ you have to configure your root directory to that path so nixpacks builds/runs from the correct directory as seen here.

though what i suspect is your package.json doesnt exist in your /backend/ directory, so its failing. railway builds and runs from /app, so if package.json isnt there, the container cant find src/server.js so it creates the SIGTERM.

perhaps you can outline what your existing app structure looks like and where package.json lives


Loading...