Azure App Service on Linux restarts the container and the site never starts
GET /robots933456.txt HTTP/1.1 404 in the container log (this means the container is healthy)Short answer
App Service sends a warmup request to the container and restarts it if no HTTP answer comes back in time. The usual reasons are the wrong port, an app that never starts listening, a slow start, or a start command that does not keep a process in the foreground. Turn on container logs first.
Fix it fast
1Find out which cause you have
Turn on container logging and read the log stream. It shows whether the app crashed, never listened, or listened on another port.
az webapp log config --name <app-name> --resource-group <group> --docker-container-logging filesystem az webapp log tail --name <app-name> --resource-group <group>2Match what you see, then jump to its fix
- 1
The app listens on a port other than 80 or 8080, and warmup failsA custom container listens on a port App Service does not knowFix - 2
Node.js runtime stack, app hard-codes a portA built-in Node.js image app ignores the PORT variableFix - 3
The log shows the app still starting when the container is restartedThe container needs longer than the warmup windowFix - 4
No reply at all to GET /robots933456.txtThe app does not answer the warmup pathFix - 5
Custom Docker image with CMD or a startup command of pm2 startA custom image runs the app through plain PM2 instead of pm2-runtimeFix
- 1
What does the error look like?
GET /robots933456.txt HTTP/1.1 404 in the container log (this means the container is healthy)The container restarts again and again and the site returns an application error
Cause 1 of 5
A custom container listens on a port App Service does not know
1Check
For a custom container App Service detects port 80 or 8080 by itself. Any other port needs the WEBSITES_PORT app setting, with a matching EXPOSE in the Dockerfile. Only one port is supported.
az webapp config appsettings list --name <app-name> --resource-group <group>2Fix
Set WEBSITES_PORT to the port your app binds to.
az webapp config appsettings set --resource-group <group> --name <app-name> --settings WEBSITES_PORT=30003Verify
The log stream shows the warmup request answered and the site responds.
curl -I https://<app-name>.azurewebsites.netConfirmed by learn.microsoft.com
Cause 2 of 5
A built-in Node.js image app ignores the PORT variable
1Check
For built-in containers the platform tells your code which port to use through the PORT environment variable.
grep -n "listen" server.js2Fix
Read PORT in the app, with a fallback for local runs.
const port = process.env.PORT || 3000;
app.listen(port);3Verify
Redeploy and watch the log stream until the app answers.
az webapp log tail --name <app-name> --resource-group <group>Confirmed by learn.microsoft.com
Cause 3 of 5
The container needs longer than the warmup window
1Check
The warmup request waits a fixed time for a reply. If the app takes longer to start than that window, the container is restarted before it is ready.
az webapp config appsettings list --name <app-name> --resource-group <group>2Fix
Raise WEBSITES_CONTAINER_START_TIME_LIMIT. The documented range is up to 1800 seconds.
az webapp config appsettings set --resource-group <group> --name <app-name> --settings WEBSITES_CONTAINER_START_TIME_LIMIT=6003Verify
The log stream shows the app start and answer the warmup request.
az webapp log tail --name <app-name> --resource-group <group>Confirmed by learn.microsoft.com
Cause 4 of 5
The app does not answer the warmup path
1Check
The warmup request goes to a dummy path, /robots933456.txt, and any status code is enough, even 404 or 5xx. If your app logic never replies to unknown paths, the warmup gets no answer and the container is restarted over and over.
curl -i http://127.0.0.1:<port>/robots933456.txt2Fix
Make unknown routes return a normal HTTP response, or set WEBSITE_WARMUP_PATH to a route you serve and WEBSITE_WARMUP_STATUSES to the codes that count as ready.
az webapp config appsettings set --resource-group <group> --name <app-name> --settings WEBSITE_WARMUP_PATH=/health3Verify
The log shows the warmup path answered.
az webapp log tail --name <app-name> --resource-group <group>Confirmed by learn.microsoft.com
Cause 5 of 5
A custom image runs the app through plain PM2 instead of pm2-runtime
1Check
PM2's own Docker guide says to run pm2-runtime as the container command instead of the plain node or pm2 start.
grep -n "CMD\|ENTRYPOINT" Dockerfile2Fix
Switch the command to pm2-runtime.
# Dockerfile
CMD ["pm2-runtime", "ecosystem.config.js"]3Verify
Rebuild, push the image and watch the log stream until the app answers.
az webapp log tail --name <app-name> --resource-group <group>Confirmed by pm2.keymetrics.io
How do I stop it coming back?
- Add a lightweight /health route and set WEBSITE_WARMUP_PATH to it.
- Keep one port in the Dockerfile, in WEBSITES_PORT and in the code.
- Do slow work such as migrations after the server starts listening, not before.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
Related fixes
Servers
nginx 502 Bad Gateway in front of a Node.js app
connect() failed (111: Connection refused) while connecting to upstream
A 502 means nginx reached for your Node.js app and got nothing usable back.
5 causes, each with a fixServers
The shell cannot find pm2 after you installed it
bash: pm2: command not found
The shell found no pm2 file in any folder of PATH.
3 causes, each with a fixServers
The SSH@0 task cannot log in to the remote machine
All configured authentication methods failed
The SSH task logs in with the details stored in its SSH service connection, so the failure is almost always in that connection or on the server.
4 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A native Node.js module fails on AWS Lambda with invalid ELF header
Error: /var/task/node_modules/<package>/build/Release/<name>.node: invalid ELF header
Lambda loads native addons on Linux, so a .node file built on macOS or Windows is not a valid Linux ELF file there.
3 causes, each with a fixServers
nginx gives up waiting for the app and returns 504
upstream timed out (110: Connection timed out) while reading response header from upstream
nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.
5 causes, each with a fix