Node.JS - Page Keeps On Running
Solution 1:
This is what I get with curl:
$ curl -vv localhost:8000
* About to connect() to localhost port 8000 (#0)
* Trying ::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain
< Connection: keep-alive
< Transfer-Encoding: chunked
<
Hello World
* Connection #0 to host localhost left intact
* Closing connection #0
nothing wrong with it. Try updating node to the latest stable version (but I don't see how it can help) and be sure any process except node is owning the tcp port 8000.
Solution 2:
In my mind, this is either one of two things:
- Node does not recieve the request
- Node does not respond to the request
To test for either, change your code:
// app.js
var http = require('http');
http.createServer(function (req, res) {
console.log('got a request');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8000/');
Try again. If node does not get the request, try changing the port to 80 instead of 8000, I had a funny case with firefox blocking non-conventional ports a couple of weeks ago.
Let me know how you go
Solution 3:
Have you checked your Anti Virus or Windows Firewall?
Whichever one you use you might want create a temp exception or disable it for a while just to make sure nothing is getting in the way there.
Solution 4:
Try changing your listen address to 0.0.0.0. Maybe you're having problems binding to that specific loopback.
Post a Comment for "Node.JS - Page Keeps On Running"