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

综合技术 2018-02-15 阅读原文

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 Worldn');
}).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 (!)

Problem courtesy of: oblio

Node.js Recipes

责编内容by:Node.js Recipes阅读原文】。感谢您的支持!

您可能感兴趣的

Win 7 用户如何在 Outlook 和 Thunderbird 中直接输入 Emoji... 如果你需要在 Outlook 或者 Mozilla Thunderbird 客户端中使用 Emoji 表情符号,又不希望跳出应用本身直接调用 Emoji,今...
translate xml to json in node.js Node.js Recipes are structured in a Cookbook format featuring recipes that...
Is there any node-waf for Node.js on windows? I am trying to install the 'png' module from Node.js using the fol...
Node.js for “traditional” sites I'm digging into Node.js now and the whole idea seems brilliant to me. But...
nodejs 和 homebridge 我前几天说写了一个插件,可以让小米的ZigBee网关与苹果的HomeKit对接,这个插件写的差不多了,也已经上传到了npm社区上面,有兴趣的可以去看看: h...