Shekhar Reddy
Shekhar Reddy

Reputation: 155

Unable to start the nodeapp through terminal

I have a node app locally and I normally run it using the run button in the web storm, which works fine. While I am documenting the project I came across this blocker: if I try running the same app through the terminal using the command: node app.js , the server starts but the browser throws and error stating "This site can’t be reached" "localhost refused to connect".

Upvotes: 2

Views: 69

Answers (2)

Shekhar Reddy
Shekhar Reddy

Reputation: 155

I found this myself.. since I used the scaffolding app and it stores info related to server at bin/www, so we will not be able to run the app using the command : node app.js but instead we could run the app using nodemon(which I installed globally on my machine)

Love nodemon for this awesome feature <3 :)

Upvotes: 1

Ebrahim Pasbani
Ebrahim Pasbani

Reputation: 9396

Because the port is occupied.

You can change it using app.listen({port})...

or

linux: export PORT=4500 node server.js

windows: set PORT=4500 node server.js

Upvotes: 2

Related Questions