I am trying to use PM2 on Azure App Service Linux running a simple Node.js/Express application. The configuration file for PM2 is like this:
module.exports = {
apps: [
{
name: "myapi",
script: "./src/index.js",
env: {
NODE_ENV: "development",
PORT: 3000,
},
env_test: {
NODE_ENV: "test",
PORT: 8081,
},
env_production: {
NODE_ENV: "production",
PORT: 8080,
}
}
]
};
The startup command is like
pm2-runtime start ecosystem.config.js --env test
The deployment is fine. But I can only use PORT = 8080. If I use port 8081, I got the 504 gateway timeout error.
What might be the problem?



WEBSITE_PORThas been set to 8080. You need to update that or useEXPOSEon the container to open other ports.process.env.PORT || 8080in your configuration file.