Oops! 10000 points to jimw!
I'm trying to start a hobby project using Node. So I got going:
and then I get this:
Firefox can't establish a connection to the server at 127.0.0.1.
Code:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Any ideas? Right now I'm kind of baffled that "Hello world" isn't working (!)
I don't know how to close the question, so I'll just answer myself. jimw's comment was the answer - I was trying to access the wrong port because I entered localhost/1337 instead of localhost:1337 , I was just blind.
Thanks a lot;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.