2

I'm using Express 4 installed on an amazon ec2-server. I was wondering why I can't access my server with the public-ip:8000/

Here is my code for the server:

var express = require('express');
var http = require('http');
var app = express();

http.createServer(app).listen(8000);

app.get('/', function (req, res) {
  res.send('Hello World!')
});
Arjun Patel
  • 266
  • 5
  • 18

1 Answers1

1

First, you aren't setting up the Express and HTTP server correctly; ExpressJS is itself a wrapper for the HTTP module. This would be a correct setup:

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(8000);

Edit: the issue actually had to do with the firewall of the server (along with the app). This answer helped solve the issue.

Community
  • 1
  • 1
Brendan
  • 2,777
  • 1
  • 18
  • 33
  • Yea, that doesn't work either. If it is a firewall. I guess it is as firewall issue. How can I troubleshoot it? – Arjun Patel Oct 19 '14 at 05:06
  • 3
    @ArjunPatel sorry my original answer didn't fix it - maybe [this answer](http://stackoverflow.com/a/10454688/2708970) will help. – Brendan Oct 19 '14 at 05:11
  • @ArjunPatel you're welcome - I've edited this answer to include the answer link and explanation. :) – Brendan Oct 19 '14 at 05:34