Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Web App on Linux: "Error: Container didn't respond to HTTP pings on port: 8080" - when using: "start": "pm2 start server.js"

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.

I would really appreciate any suggestion, Thanks.

like image 412
Edmond Tamas Avatar asked Apr 15 '19 11:04

Edmond Tamas


People also ask

How do I specify port in my Linux container?

How do I specify port in my Linux container? If you select a language/framework version for a Linux app, a predefined container is selected for you. To point your app code to the right port, use the PORT environment variable. You have full control over the container.

How do I enable SSH on my Azure Web App?

Open SSH session from remote shell To get started, you need to install Azure CLI. To see how it works without installing Azure CLI, open Azure Cloud Shell. Open a remote connection to your app using the az webapp create-remote-connection command. Specify <subscription-id>, <group-name> and <app-name> for your app.


1 Answers

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.

  1. Use the EXPOSE instruction in your Dockerfile to expose port 8080.
  2. Use the WEBSITES_PORT app setting with a value of "8080" to expose that port.

You can refer the below mentioned articles:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops

https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/

like image 61
DashleenBhandari-MSFT Avatar answered Oct 20 '22 21:10

DashleenBhandari-MSFT