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 CommandorRoot Directorysetting in the Railway project config.
What I’ve tried:
Ensured
src/server.jsexists and works locally (npm startruns fine).Set the
Start Commandtonpm start.Tried setting
Root Directoryin Railway to/and tobackend/, 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" } }
5 Replies
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.
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
srcwhich seems legit. Looks like the container spins up successfully & after a minute or so throws these errors & shuts down.
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
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
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