Reputation: 145
I have been trying to figure out why i cant get even the most basic Node.js application to run, all day. I have installed Node on my Media Temple (dv) server in the root using PuTTy NOT on my local machine.
When i do 'node --version' it shows me the version, which tells me that Node is correctly installed. However when i attempt to do the basic 'HTTP' example it doesnt work when i go to http://mysite.com:1337, instead the connection just times out.
The JS is below:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "mysite.com");
console.log('Server running at http://mysite.com:1337/');
Node.js really interests me so would be good if i can understand why it isnt working.
Thanks in advance.
Upvotes: 2
Views: 2776
Reputation: 63683
How about:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337);
console.log('Server running at http://mysite.com:1337/');
Without specifying the host?
Upvotes: 3
Reputation: 45578
Change listen(1337, "mysite.com")
to listen(1337, "0.0.0.0")
, that should work.
Upvotes: 2