How to run Nodejs App On Different Port Other Than Default 8080?

Shubham Saini 40 Reputation points
2023-12-29T18:42:51.77+00:00

I followed the link to create my first nodejs app in the app service

https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=linux&pivots=development-environment-vscode

but my app is running on port 8080 not 3000. I even added a new variable PORT:3000 in configuration>application settings but it didn't help.

Can someone please help on how one can use a different port?

Thanks

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 14,180 Reputation points MVP
    2023-12-29T23:00:22.89+00:00

    Set the PORT variable first

    Azure Portal > Configuration > Application settings > Add a new application setting
    PORT = 3000

    then Check your app settings also

    const port = process.env.PORT || 3000;  
    app.listen(port, () => {
        console.log(`Server listening on port ${port}`);
    });
    
    
    

    then restart the application

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.