title: ng serve error: getaddrinfo ENOTFOUND localhost
body: <p>I was getting this error:</p>
  
  <pre><code>getaddrinfo ENOTFOUND localhost
  Error: getaddrinfo ENOTFOUND localhost
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
  </code></pre>
  
  <p>when running <code>ng serve</code>. After web lookup, the proposed answer to this problem is to run this command instead:</p>
  
  <pre><code>ng serve --port 4200 --host 0.0.0.0
  </code></pre>
  
  <p>Unfortunately, the instructions came without explanation.</p>
  
  <p>This works and the Angular project compiled successfully. I am not sure why. Can someone explain why this works and what has happened in the background? Thanks</p>