title: NodeJS - Error: listen EADDRNOTAVAIL: address not available
body: <p>I am running a Node app that should be hosted on a local server.
  At the moment, I am sending just a plaintext response.</p>
  
  <pre><code>const http = require('http');
  
  var server = http.createServer(function(req, res) {
    res.writeHead(200, {ContentType: 'text/plain'});
    res.end("test");
  });
  </code></pre>
  
  <p>When I listen to the localhost everything works fine and I am able to send the request from my browser.</p>
  
  <pre><code>server.listen(3000, '127.0.0.1'); // works fine, on the same machine
  </code></pre>
  
  <p>However, if I try to listen to a port on my LAN network by typing the router's IP, I get an error.</p>
  
  <pre><code>server.listen(3000, '192.168.0.1'); // causes an error
  </code></pre>
  
  <pre><code>Error: listen EADDRNOTAVAIL: address not available 192.168.0.1:3
  000
      at Server.setupListenHandle [as _listen2] (net.js:1253:19)
      at listenInCluster (net.js:1318:12)
      at doListen (net.js:1451:7)
      at process._tickCallback (internal/process/next_tick.js:63:1
  9)
      at Function.Module.runMain (internal/modules/cjs/loader.js:7
  57:11)
      at startup (internal/bootstrap/node.js:283:19)
      at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
  Emitted 'error' event at:
      at emitErrorNT (net.js:1297:8)
      at process._tickCallback (internal/process/next_tick.js:63:1
  9)
      [... lines matching original stack trace ...]
      at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
  </code></pre>
  
  <p>I have tried this with my public IP address unsuccessfully. 
  Is there any way to listen to a port on a LAN server so that I can send requests from any computer on the network?
  <br />
  Also, I would later like my application to run on any computer on any LAN network. How can I dynamically add my host?</p>