Thomson Thomson - 2 months ago 16
Node.js Question

Node js unable to connect using http://127.0.0.1:3000

Hi I am very new to Node JS and I am trying to learn through Sams teach yourself in 24 hours. I have installed express globally and was following exactly book says.Installed express globally.

express jade_conditions


installed dependencies

cd jade_conditions && npm install


and ran

node app.js


and then asked to open browser with node http://127.0.0.1:3000/
and here is the problem because I am not able to open any site. It says Unable to connect. Am I missing anything. Because I dont understand where is this http://127.0.0.1:3000/ coming from. Can anyone help me how to see those jade.index file from the view folder on the browser ?
Thanks in advance.

Answer

If you creates an app with express-generator then it won't be work with node app.js since listen configuration has been done in bin/www folder and it will run with start command

Do this

> npm start

And open your above link on broswer

And if you want to use node app.js then listen it on a particular port in your app.js file like this

> app.listen(3000); 

And use node app.js and it will work

For reference check it in details here: https://github.com/expressjs/express#quick-start