title: Http-server nodejs running but not working
body: <p>I am trying to run http-server for nodejs. </p>
  
  <p>After using <code>npm start</code> the server starts on the given port(8000) perfectly with a few ignorable errors. But when I try to run the application url, it says 'Webpage is not available'.
  When i tried to <code>ping</code> the IP it responds by sending packets perfectly.</p>
  
  <p>When I run <code>http-server</code> command it shows that it is running on 127.0.0.1:8080 and 172.31.46.121:8080. I tried changing the localhost port to 8080,but with no difference in results.</p>
  
  <p>I am using putty client to run linux on windows.</p>
  
  <p><strong>nodejs version</strong>-5.4.1</p>
  
  <p><strong>npm version</strong>-3.7.0</p>
  
  <p>Please help..</p>
  
  <p>There is one more thing..</p>
  
  <p>I ran this server on putty at port 80. Then with the server still running i tried to run the same nodejs server using Bitnami client(i.e. using <code>npm start</code>) at the same port(80) and <strong>there was no conflict of ports</strong>. Even the app is running fine at that port when I run it through Bitnami client.</p>
  
  <p>http-server file code-</p>
  
  <pre><code>` #!/usr/bin/env node
  
  var colors = require('colors'),
  httpServer = require('../lib/http-server'),
  argv = require('optimist').argv,
  portfinder = require('portfinder'),
  opener = require('opener');
  
  if (argv.h || argv.help) {
  console.log([
  "usage: http-server [path] [options]",
  "",
  "options:",
  "  -p                 Port to use [8080]",
  "  -a                 Address to use [0.0.0.0]",
  "  -d                 Show directory listings [true]",
  "  -i                 Display autoIndex [true]",
  "  -e --ext           Default file extension if none supplied [none]",
  "  -s --silent        Suppress log messages from output",
  "  --cors             Enable CORS via the 'Access-Control-Allow-Origin'       header",
  "  -o                 Open browser window after staring the server",
  "  -c                 Set cache time (in seconds). e.g. -c10 for 10 seconds.",
  "                     To disable caching, use -c-1.",
  "  -h --help          Print this list and exit."
   ].join('\n'));
  process.exit();
  }
  
  var port = argv.p || parseInt(process.env.PORT, 10),
  host = argv.a || '0.0.0.0',
  log = (argv.s || argv.silent) ? (function () {}) : console.log,
  requestLogger;
  
  if (!argv.s &amp;&amp; !argv.silent) {
  requestLogger = function(req) {
  log('[%s] "%s %s" "%s"', (new Date).toUTCString(), req.method.cyan,     req.url.cyan, req.headers['user-agent']);
  }
  }
  if (!port) {
  portfinder.basePort = 8080;
  portfinder.getPort(function (err, port) {
  if (err) throw err;
  listen(port);
  });
  } else {
  listen(port);
  }
  
  function listen(port) {
  var options = {
  root: argv._[0],
  cache: argv.c,
  showDir: argv.d,
  autoIndex: argv.i,
  ext: argv.e || argv.ext,
  logFn: requestLogger
  };
  
  if (argv.cors) {
  options.headers = { 'Access-Control-Allow-Origin': '*' };
  }
  
  var server = httpServer.createServer(options);
  server.listen(port, host, function() {
  log('Starting up http-server, serving '.yellow
    + server.root.cyan
    + ' on port: '.yellow
    + port.toString().cyan);
   log('Hit CTRL-C to stop the server');
  
  if (argv.o) {
    opener('http://127.0.0.1:' + port.toString());
  }
  });
  }
  
  if (process.platform !== 'win32') {
  //
  // Signal handlers don't work on Windows.
  //
  process.on('SIGINT', function () {
  log('http-server stopped.'.red);
  process.exit();
  });
  }
  </code></pre>
  
  <p>`</p>