title: Wait Until Webpack Dev Server Is Ready
body: <p><strong>Requirements</strong></p>
  
  <p>I need to run the webpack-dev-server and wait until the server is ready to serve pages.</p>
  
  <p><strong>Solution</strong></p>
  
  <pre><code>// Start a webpack-dev-server
  new WebpackDevServer(webpack(myConfig), {
      publicPath: myConfig.output.publicPath,
      hot: true,
      historyApiFallback: true,
      // It suppress error shown in console, so it has to be set to false.
      quiet: false,
      // It suppress everything except error, so it has to be set to false as well
      // to see success build.
      noInfo: false,
      stats: {
          // Config for minimal console.log mess.
          assets: false,
          colors: true,
          version: false,
          hash: false,
          timings: false,
          chunks: false,
          chunkModules: false
      }
  }).listen(3000, '0.0.0.0', function(err) {
      if(err) throw new gutil.PluginError('webpack-dev-server', err);
      gutil.log('[webpack-dev-server]', 'http://0.0.0.0:3000/webpack-dev-server/index.html');
      //this is to ensure that end to end test wouldn't start running until the server is ready
      http.get({
          hostname: '0.0.0.0',
          port: 3000,
          path: '/',
          agent: false  // create a new agent just for this one request
      }, (/*res*/) =&gt; {
          // Do stuff with response
          done();
      });
  });
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>On Linux a have a wait until the server is ready. On Windows I get an exception because there is no wait and the server is not ready</p>
  
  <blockquote>
    <p>C:\development\ucms-react>gulp webpack-dev-server [11:03:01] Requiring
    external module babel-register [11:03:07] Using gulpfile
    C:\development\ucms-react\gulpfile.babel.js [11:03:07] Starting
    'webpack-dev-server'... [11:03:07] [webpack-dev-server]
    <a href="http://0.0.0.0:3000/webpack-dev-server/index.html" rel="noreferrer">http://0.0.0.0:3000/webpack-dev-server/index.html</a> error events.js:141
          throw er; // Unhandled 'error' event
          ^</p>
    
    <p>Error: connect EADDRNOTAVAIL 0.0.0.0:3000
        at Object.exports._errnoException (util.js:907:11)
        at exports._exceptionWithHostPort (util.js:930:20)
        at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1077:14)</p>
    
    <p>C:\development\ucms-react></p>
  </blockquote>
  
  <p>How can I solve this issue?</p>