I'm trying to write a node.js application, trying to make sure my environment set up first.
The webserver is Fedora 21, and I have opened port 3000 on the firewall and flushed ip tables. nmap localhost indicates that port 3000 is listening.
I'm using this node application
var http = require('http');
var PORT = process.env.PORT || 3000;
http.createServer(function (req, res) {
console.log('%d request received', process.pid);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello world!\n');
}).listen(PORT);
console.log('%d listening on %d', process.pid, PORT);
But when I navigate the browser to my server I don't get any hello world message like intended.
Perhaps check for firewall rules? IIRC many firewalls prefer to drop packets instead of actively rejecting -- so you may find that (eventually) the web browser times out. Easy way to check: In one console, do: nc -l -p {whatever your PORT environment variable is set to, or 3000, as per your server logic} and in another console, do echo hello | nc localhost 9999
If you see the hello in the first console, you can at least rule out some tcp oddness / firewall issue.