title: Netcat Server Connection Refused
body: <p>Using netcat, I need to create a simple server to respond with simple JSON data.</p>
  
  <p>First I am trying with an HTML page:</p>
  
  <pre><code>while true ; do nc -l 8888  &lt; index.html ; done
  </code></pre>
  
  <p>or even more simply:</p>
  
  <pre><code>netcat -l 8888 &lt; index.html
  </code></pre>
  
  <p>And then in my browser I do this:</p>
  
  <pre><code>http://localhost:8888/index.html
  </code></pre>
  
  <p>I also try to connect using netcat:</p>
  
  <pre><code>nc -vz 127.0.0.1 8888
  </code></pre>
  
  <p>Each of these yields a 'connection refused' result:</p>
  
  <blockquote>
    <p>localhost [127.0.0.1] 8888 (ddi-tcp-1): Connection refused</p>
  </blockquote>
  
  <p>How do I resolve this error?</p>