Node.Js - Unable to connect to server

0 rajadurai kanniappan · September 21, 2015
Hi all, I typed the same code as i have seen in the Bucky's video. But the server is not connecting to browser (the page http: localhost:8888 is not opening in the browser) I have also checked the firewall settings, permission is already given to Node.js.

var http = require('http');

function onRequest(request, response){
console.log("A user made a request" + request.url);
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Here is some data");
response.end();
}

http.createServer(onRequest).listen(8888);
console.log("Server is now running...");

Any guidance would be rally helpful to me.

Post a Reply

Replies

Oldest  Newest  Rating
0 ken Doe · December 24, 2015
It worked on mine. This maybe like one of those "have you plugged in the device suggestion" but did you run it with: node yourfile.js?
0 Chathula Sampath · December 10, 2015
try another port and inform us. 
0 Anton Wieslander · January 9, 2016
I can't believe i was beating my head for an hour where the only error was that it automatically runs app.js,
needed to just fucking right click on myfile.js and press run...
0 Ananth T · November 28, 2015
may be try giving some other port
  • 1

Node.js

87 followers
About

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Links
Moderators