0

Hi all
i am new to Node.js
i followed the tutorial and typed the following

var sys = require("util"),
    http = require("http");

http.createServer(function(request, response) {
    response.sendHeader(200, {"Content-Type": "text/html"});
    response.write("Hello World!");
    response.close();
}).listen(8080);

sys.puts("Server running at http://localhost:1331/");

its running fine while i run it through cmd
but when i open my browser and type the url i.e. http://localhost:1331,
it says
failed to open requested URL

do i have to setup any web server for it??? or Node.js does it itself???

2
Contributors
6
Replies
10
Views
5 Years
Discussion Span
Last Post by baig772
1

it worked,
i changed my code to this

var sys = require("util"),
    http = require("http");

http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/html"});
    response.write("Hello World!");
    //response.close();
}).listen(8090);

sys.puts("Server running at http://localhost:8090/");
1

i commented

response.close()

because i was following an old tutorial.
please change this to

response.end()
Votes + Comments
Thanks for sharing.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.