Ryan
Ryan

Reputation: 6057

Why doesn't my Node.js server reply with data?

I'm doing the tutorial here. I got everything working up until this point:

var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello Http'); 
});

server.listen(8080);

When I run the above using node hello_http.js it doesn't exit as expected but then when I view localhost:8080 in the browser there's nothing and when I curl it I get this:

curl: (52) Empty reply from server

How should I look for the problem? One thing I should add is that I was playing around with Cherrypy a couple weeks ago and when I visit localhost in my browser I see the Cherrypy favicon. Is Cherrypy interfering with this in some way?

Upvotes: 0

Views: 1084

Answers (1)

Pickels
Pickels

Reputation: 34630

Change the port from 8080 to 3000. 8080 is common port so you are most likely correct that an other server is using it.

Upvotes: 2

Related Questions