Recently, my web app created on Azure using Express and Node 18 worked perfectly during development locally. However, when I attempted to host it on an Azure web app, I encountered issues. The site failed to display anything and a 403 error was returned in the console. Even when attempting to SSH into the server for more information:
Pinging app default url...
Ping responded with status code: 403
Checking status, body: {"port":2222,"state":"STOPPED","canReachPort":false,"msg":"Unable to connect to WebApp"}
I've searched for solutions online, but most refer to a Dockerfile, which is supposedly created when sending the app to Azure. I'm unsure about how to modify this file, yet I seem to be encountering similar errors (
Container didn't respond to HTTP pings on port 8080, failing site start
)
Experimented by setting the Express port to 3000, 443, and 8080, as well as altering the WEBSITE_PORT and PORT environment variables, all without positive results.
import express from "express";
import session from "express-session";
const app = express(); // Create express app
app.listen(process.env.PORT); // Listen on port 8080
As a newcomer to Express and Azure, the somewhat perplexing nature of the Azure portal has made troubleshooting more challenging. Any guidance would be greatly appreciated!