简体   繁体   中英

Connection aborted while running the Node.js "hello world" on Windows 7

Answered/fixed:

Oops! 10000 points to jimw!

I'm trying to start a hobby project using Node. So I got going:

  • installed Node 0.6.14
  • copy-pasted the "hello world" program from their homepage in Eclipse
  • saved as Main.js
  • launched (node Main.js)
  • opened http://127.0.0.1/1337
  • 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/');
  1. Firebug output: Aborted - 127.0.0.1
  2. Windows Firewall disabled - same result.
  3. Checked.netstat:.netstat -na | findstr 1337: TCP 127.0.0.1:1337 0.0.0.0:0 LISTENING
  4. Checked that Node is running - it was.
  5. Changed the port - same result.
  6. Tried to find Node server logs - can't seem to find any.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM