This has been solved. Even though port 8080 was exposed, I had to connect from vue with the node server https://node_servername not https://node_servername:8080 like I did when I ran it local (i.e https://localhost:8080)
Cannot connect to node app service running on port 8080
I have deployed a node.js app through visual studio code to azure app service. It has deployed correctly.
The bin/ww file has
var WEBSITE_PORT = process.env.PORT || 8080;
var port = normalizePort(process.env.PORT || '8080');
The server.js file has:
const PORT = process.env.PORT || 8080;
const WEBSITE_PORT = process.env.PORT || 8080;
app.listen(WEBSITE_PORT, () => {
console.log(Server is running on port ${WEBSITE_PORT}.
);
and the logs show:
2024-02-13T18:41:01.203399149Z Server is running on port 8080.
2024-02-13T18:41:01.563822371Z Executing (default): SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = 'tutorials' AND TABLE_SCHEMA = 'cruddb1'
2024-02-13T18:41:01.603821829Z Executing (default): SHOW INDEX FROM tutorials
2024-02-13T18:41:01.641100796Z Synced db.
However it will not connect to my vue app using http://myserver....:8080
Azure App Service
2 answers
Sort by: Most helpful
-
Joe OConnor 5 Reputation points
2024-02-17T15:56:33.9266667+00:00 -
SnehaAgrawal-MSFT 22,706 Reputation points Moderator
2024-02-20T07:55:02.9033333+00:00 @Joe OConnor Glad that you were able to resolve your issue and I appreciate your effort in sharing the solution. Your contribution will undoubtedly assist others facing similar challenges.
As the Microsoft Q&A community follows a policy where the question author cannot accept their own answer
I've reposted your solution. Feel free to consider "Accepting" the answer if you find it suitable.
Problem: Difficulty Connecting to Node App Service on Port 8080
Description: Users encountered difficulty connecting to a Node.js application service running on port 8080.
Solution: The issue has been resolved by adjusting as below. Despite port 8080 being exposed, it was necessary to connect from the Vue.js frontend to the Node.js server using the HTTPS protocol without specifying the port number. Previously, the connection was established using the port 8080 when running locally (i.e., https://localhost:8080). However, in the deployed environment, the connection needed to be made directly to the Node server without specifying the port, like so: https://node_servername
Refer to this doc link and best practices- https://learn.microsoft.com/en-us/azure/app-service/configure-language-nodejs?pivots=platform-linux#configure-nodejs-server
Thanks again.