Webpack-dev-server: open option with host set to 0.0.0.0 opens page that won't load in browser

Created on 26 Nov 2017  路  4Comments  路  Source: webpack/webpack-dev-server

I'm setting host = '0.0.0.0 to test the page on devices on my local network (iPhone, iPad, etc.). I'm also using open = true (default setting) to automatically open a browser window on startup. Unfortunately it opens the window at 0.0.0.0:8000 instead of localhost:8000. And consequently no page loads. I can fix this by setting useLocalIp = true, but I think that's counter-intuitive and works slightly different to what I really want (localhost). Could you improve this? Maybe set it to localhost automatically if the host is 0.0.0.0.

Most helpful comment

"webpack": "4.16.1"

  devServer: {
    hot: true,
    host: '0.0.0.0',
    port: 3000,
    open: true,
    openPage: 'dashboard/',
    publicPath: '/dashboard/',
    contentBase: path.join(__dirname, 'Build'),
    historyApiFallback: true
  },

in browser : http://0.0.0.0:3000/dashboard/


  devServer: {
    hot: true,
    host: '0.0.0.0',
    port: 3000,
    open: true,
    openPage: 'dashboard/',
    public: 'localhost:3000',
    publicPath: '/dashboard/',
    contentBase: path.join(__dirname, 'Build'),
    historyApiFallback: true
  },

work.

All 4 comments

Closing as invalid. Please see the issue template.

I also encountered the same problem hate bad

@ipengyo Would you open another issue that follows their "template"?

"webpack": "4.16.1"

  devServer: {
    hot: true,
    host: '0.0.0.0',
    port: 3000,
    open: true,
    openPage: 'dashboard/',
    publicPath: '/dashboard/',
    contentBase: path.join(__dirname, 'Build'),
    historyApiFallback: true
  },

in browser : http://0.0.0.0:3000/dashboard/


  devServer: {
    hot: true,
    host: '0.0.0.0',
    port: 3000,
    open: true,
    openPage: 'dashboard/',
    public: 'localhost:3000',
    publicPath: '/dashboard/',
    contentBase: path.join(__dirname, 'Build'),
    historyApiFallback: true
  },

work.

Was this page helpful?
0 / 5 - 0 ratings