admin管理员组文章数量:1335669
"I am deploying a Node.js application using PM2 on an Azure App Service. The application appears to start successfully, but it fails the HTTP health check on port 8080, and the site does not start."
"The application should respond to HTTP pings on port 8080, allowing the App Service to start successfully."
"I am deploying a Node.js application using PM2 on an Azure App Service. The application appears to start successfully, but it fails the HTTP health check on port 8080, and the site does not start."
"The application should respond to HTTP pings on port 8080, allowing the App Service to start successfully."
Share Improve this question asked Nov 20, 2024 at 8:19 gokul dotechgokul dotech 1 5- Ensure you define your port as follows: const port = process.env.PORT || 8080; in your code. – Aslesha Kantamsetti Commented Nov 20, 2024 at 8:30
- If possible, share your code? – Aslesha Kantamsetti Commented Nov 21, 2024 at 7:19
- Can you connect and solve the issue ? – gokul dotech Commented Nov 21, 2024 at 7:40
- I Give linkedIn Connection – gokul dotech Commented Nov 21, 2024 at 7:41
- If you encounter any issues, please reach out here only. – Aslesha Kantamsetti Commented Nov 21, 2024 at 9:02
1 Answer
Reset to default 0I created simple Nodejs app with PM2 deployed to the Azure App service.
Even I got the same error when hardcoded the port value in the server.js and ecosystem.config.js.
Azure App Service expects the application to listen on the port specified by the PORT environment variable
.
I define the port
value as below
const port = process.env.PORT || 8080;
server.js:
const express = require('express');
const app = express();
const port = process.env.PORT || 8080;
app.get('/', (req, res) => {
res.send('Hello, World! Application is running.');
});
app.listen(port, () => {
console.log(`Server is listening on port ${port}`);
});
ecosystem.config.js:
module.exports = {
apps: [
{
name: "nodejs-app",
script: "./server.js",
env: {
PORT: 8080
},
env_production: {
NODE_ENV: "production",
PORT: process.env.PORT
}
}
]
};
After successfully deploying the application, I set the following startup command in Azure Web App under Configuration -> Startup Command.
pm2 start ecosystem.config.js --no-daemon
Azure Web App Output:
本文标签:
版权声明:本文标题:node.js - Container stockmgmt_0_3b1a53ce didn't respond to HTTP pings on port: 8080, failing site start. See container l 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742372191a2462434.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论