Jump to content

Initiate the Node.js File. Ports problem?


Recommended Posts

I try to learn Node.js. I followed that tutorial: https://www.w3schools.com/nodejs/nodejs_get_started.asp

As the tutorial says, I created a file: myfirst.js with that content: 

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');

I have a Mac. I open the Terminal and reach that file: Your Name>node myfirst.js

I open a browser and type the address: http://localhost:8080 And I see nothing. Safari says: Safari can't connect to the Server. Similar with other browsers. 

What is wrong?


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...