title: Express.JS net::ERR_CONNECTION_REFUSED for static assets
body: <p>So I'm making a simple Express.JS web app.
  I have some assets in /public (for example, <code>public/images/main-back.png</code> ).
  In index.scss I do:</p>
  
  <pre><code>background-image: url('../../../images/main-back.png');
  </code></pre>
  
  <p>And in Chrome console I get an error:</p>
  
  <pre><code>GET http://localhost:3000/images/main-back.png net::ERR_CONNECTION_REFUSED
  </code></pre>
  
  <p>When I refresh the page several times, this request may pass one time and the image will show on the page.</p>
  
  <p>The configuration is more or less default, I have the default bin/www file. It listens on port 3000:</p>
  
  <pre><code>var server = http.createServer(app);
  
  /**
   * Listen on provided port, on all network interfaces.
   */
  
  server.listen(port);
  </code></pre>
  
  <p>The app has pre-configured assets serving by default. in app.js I have:</p>
  
  <pre><code>app.use(express.static(path.join(__dirname, 'public')));
  </code></pre>
  
  <p>The question is - why is it not working?</p>
  
  <p>UPD: In the default project which was created by Express generator, there is</p>
  
  <p>app.use(express.static(path.join(__dirname, 'public')));</p>
  
  <p>in app.js. I added app.use(sassMiddleware) before this app.use, and this leaded to the bug I'm talking about. But when I place the app.use(sassMiddleware) after the </p>
  
  <pre><code>app.use(express.static(path.join(__dirname, 'public')));
  </code></pre>
  
  <p>Then the css files don't update on scss file change. What should I do?</p>