webpack-dev-server: 1.13.0 [WS] Disconnected, net::ERR_CONNECTION_REFUSED

For versions greater than 1.12.1 The WebSocket connection seems to be broken.

In the console I get the errors:

GET http://localhost/info?t=1448470960512 net::ERR_CONNECTION_REFUSED
[WDS] Disconnected!

My Webpack Config looks like this:

{
//....
plugins: [
    new webpack.HotModuleReplacementPlugin(),
],
devServer: {
    contentBase: "./app/static",
    port: 3000,

    inline: true,
    historyApiFallback: true,

    colors: true,
    stats: 'normal',
},
}

As you can see the port is set to 3000 and I also access the page via http://localhost:3000/ but the WebSocket connections seems to ignore the port and tries to connect to http://localhost/info

I am new to webpack so I am not quite sure if I am doing something wrong but as it was working a few days ago and also works if I downgrade to 1.12.1 I suppose it’s an error with webpack-dev-server.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 3
  • Comments: 33 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Nope, it was my webpack config.

changing the first line in the App array fixed it. webpack-dev-server/client?http://localhost:8080/

fixed:

webpack-config.js

    entry:{             
            app:[
                 //'webpack-dev-server/client?http://localhost:3001',
                 //'webpack/hot/dev-server',
                'webpack-hot-middleware/client?path=http://localhost:3001/__webpack_hmr',
                  path.resolve(appPath, '../src/client.js')
                 ],

@timwingfield yes, we use under Rails. I fix it with changing config. Pretty much the same stuff, but I have multiply entries

module.exports = {
  context: __dirname,
  devtool: 'eval',
  entry: {
    'publisher': publisherEntries,
    'manager': managerEntries,
    'client': "webpack-dev-server/client?http://localhost:8080"
  },
  output: {
    path: __dirname + "/public/assets/build/",
    filename: "[name].js",
    publicPath: 'http://localhost:8080/'
  },
  plugins: plugins,
  module: {
    loaders: [
      { test: /\.js$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/ }
    ]
  }

Got it all working now. Thanks @SpaceK33z and @savroff

Did you make sure to use the same port in the devServer.port and webpack-dev-server/client?{url}?

FWIW, @SohKai’s fix doesn’t seem to work when --content-base is provided as an argument,

e.g. given a project in which the source is in ./src, a package.json script might be configured as:

  "scripts": {
    "start": "webpack-dev-server --hot --inline --content-base src"
   }

@timwingfield, the url should be /sockjs-node/info. Where does /assets/come from?

@SpaceK33z finally had a chance to come back to this. Looks like it’s working for others which is great, but I’m experiencing the same symptom (server logs say 15.12.18 08:10:16 404 GET /sockjs-node/info (Unknown - 1ms)). I completely reinstalled webpack-dev-server (removed the directory, installed webpack/webpack-dev-server#3d3c000df8889e8b557995e5fe918b29072c377f, and ran npm install && npm run prepublish within the webpack-dev-server directory).

Do I need to include an expicit dependency on sockjs and set up the server myself within my own app?

EDIT: I had webpack-dev-server listening to port 3001, setting up a proxy to my app running on port 8124. The requests to /sockjs-node/info were against my app port (8124), not my webpack-dev-server port (3001). Looks like proxying has changed since the version I was on previously (1.10.1), I’ll look into how proxying is supposed to work now.