Reputation: 3305
My App Service Linux instance crashes if my node app is using the start script: "start": "pm2 start server.js"
:
2019-04-15 11:36:34.432 ERROR - Container crime-digest__6ea5_0 for site crime-digest__6ea5 has exited, failing site start
2019-04-15 11:36:34.489 ERROR - Container crime-digest__6ea5_0 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
Container logs have nothing but the above error. If I use just: "start": "node server.js",
the app starts just fine.
I understand that if the container doesn't respond via 8080 the container gets stopped, but I'm having process.env.PORT
set as the port of my server so I can't figure out why the pm2 start script crashes the container.
I have a feeling that process.env.PORT
is undefined if using the above start script because of some mixup in the process but can't find any way to debug it because after the container crashes I'm unable to ssh into it any more to inspect it.
Upvotes: 31
Views: 87035
Reputation: 527
This post came up in Google results for Azure App Service time-out issue.
If you migrated to NET 8 and got this error, it's a breaking change:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port
that's why jakegb answer worked:
Use the EXPOSE instruction in your Dockerfile to expose port 8080.
Use the WEBSITES_PORT app setting with a value of "8080" to expose that port.
Or you can change container port 8080 back to 80 using ASPNETCORE_HTTP_PORTS
variable. See the above link for more recommended info.
Upvotes: 0
Reputation: 1
In case anyone use Adonis JS 6 you must make PORT and HOST variables optionals in start/env.ts :
NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const),
PORT: Env.schema.string.optional() || 3333,
APP_KEY: Env.schema.string(),
HOST: Env.schema.string.optional({ format: 'host' }),
LOG_LEVEL: Env.schema.enum(['fatal', 'error', 'warn', 'info', 'debug', 'trace'])
and quit from env variables in Azure.
Is because Azure use its own port (8080) and for HOST case uses 0.0.0.0.
Upvotes: 0
Reputation: 1075
I was having the same issue but finally found the answer. The problem on my side was that I was building the image using my MacBook M2 Max which runs on different architecture. Changing the build command to something like this
docker build --platform=linux/amd64 -t next-portfolio:latest .
has solved the issue. I was trying to deploy to Azure using AppService with Docker using Docker hub. After this all the port issue has disappeared.
Upvotes: 14
Reputation: 11
I hade the same error. For me the problem was that I build the container locally on my Mac (silicon CPU) and then pushed it to Azure, and Azure didn't like the build.
When I instead let Azure build it, it worked. I run this command to make Azure build the container:
az acr build --image <SAVE_PATH_ON_CONTAINER_REGISTRY> --registry <YOUR_CONTAINER_REGISTRY> --file Dockerfile .
Example:
az acr build --image sample/hello-world:v1 \
--registry mycontainerregistry008 \
--file Dockerfile .
Upvotes: 1
Reputation: 163
By me the issue was that the application was running on 127.0.0.1 and not on 0.0.0.0
A solution for a Flask service:
In Azure portal configuration: Set the environment variable:
WEBSITES_PORT 8000
And add a Startup Command:
flask run -h 0.0.0.0 -p 8000
You might need to run a new deployment, a restart didn't change the URL.
Upvotes: 4
Reputation: 124
I managed to solve my problem by changing the HTTPS initiate server command to HTTP. I didn't know that Microsoft already offer this service.
FROM:
var server = https.createServer(app).listen(port, ()=>{console.log('server is runing at port ' + port) });
TO:
var server = http .createServer(app) .listen(port, ()=>{ console.log('server is runing at port ' + port) });
Upvotes: 0
Reputation: 29048
I had this issue when working on Deploying a Rails Application to Azure Web App for Containers
When I deploy the app to Azure, I will get the error below:
2021-07-29T10:29:05.571Z INFO - Initiating warmup request to container devopsapptest_0_2eeeb139 for site devopsapptest
2021-07-29T10:29:07.733Z ERROR - Container devopsapptest_0_2eeeb139 for site devopsapptest has exited, failing site start
2021-07-29T10:29:07.737Z ERROR - Container devopsapptest_0_2eeeb139 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
Here's how I solved it:
By default, App Service assumes your custom container is listening on port 80
, however, my application was listening to requests on port 3000
, which led to the error.
If your container listens to a different port, set the WEBSITES_PORT
app setting in your App Service app. That is a WEBSITES_PORT
as one of your app settings with the port your app is listening to. In my case, it was 3000
.
You can set it in Azure CLI:
az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_PORT=8000
In Azure PowerShell:
Set-AzWebApp -ResourceGroupName <group-name> -Name <app-name> -AppSettings @{"WEBSITES_PORT"="8000"}
Note: App Service currently allows your container to expose only one port for HTTP requests.
You may desire to also add the EXPOSE your-port
command to the Dockerfile
of your project. However, for my project, I did not have to add the EXPOSE your-port
command, and it worked fine for me.
Note: Endeavour to redeploy the application preferably from your CICD pipeline again after this change to refresh the application.
Resources: Configure a custom container for Azure App Service.
Upvotes: 4
Reputation: 1
Had this issue. If nothing helps, make sure your web-app returns a "Not Found (404)" response for not implemented API endpoints.
Courtesy of this answer on server fault: https://serverfault.com/questions/1003418/azure-docker-app-error-site-did-not-start-within-expected-time-limit-and-co
Upvotes: 0
Reputation: 1
Might be possible that your application is taking some time to respond, docker container on azure web service wait for 230 secs to get a reply and if it crosses that time limit it will simply halt and give "container didn't respond to HTTP pings ...", u can increase this time limit by making changes to your application setting under "configuration" blade in azure app service by adding WEBSITES_CONTAINER_START_TIME_LIMIT to 420 (as needed).
Upvotes: 0
Reputation: 86
I was having the same issue. When I changed the code in my server.js file to the below it succesfully ran:
const port = process.env.port || 8080;
After redeploying to Azure it is now working.
Upvotes: 7
Reputation: 2270
Try adding the application setting PORT with the value of whatever port your app is listening on.
Ref: https://github.com/MicrosoftDocs/azure-docs/issues/34451
Upvotes: 2
Reputation: 661
Are we trying to ping on PORT 8080? The problem here is that port 8080 is not exposed, so when we attempt to ping the container, we aren't pinging on a port on which the container is listening.
There are a couple of ways to resolve this.
You can refer the below mentioned articles:
https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/
Upvotes: 10