Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

The webpack dev server client reports it is disconnected and stops reloading

Error[WDS] Disconnected!

Short answer

The page lost the WebSocket it uses for live reload. Either the dev server process stopped, or the page is trying to reach it at the wrong address, which happens behind a proxy, a tunnel or a different hostname. Tell the client where the socket is with client.webSocketURL and allow the host you browse from.

  • Applies to webpack 5, webpack-dev-server 5, React 19, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check that the dev server is still running and answering on its own port, before you change any config.

    ps aux | grep -i webpack | grep -v grep
    curl -I http://localhost:8080
  2. 2Match what you see, then jump to its fix

    1. 1The terminal shows a crash, or the process is gone; the page keeps the old contentThe dev server process stopped or restartedFix
    2. 2The site is opened through a reverse proxy, a tunnel or a container port, not directly on localhostThe page cannot reach the socket through a proxy or tunnelFix
    3. 3Opening the app by a LAN name or a custom domain works but live reload is deadThe host name you browse from is not allowedFix

What does the error look like?

  • [WDS] Disconnected!

Cause 1 of 3

The dev server process stopped or restarted

1Check

Read the terminal that runs the dev server. The client tries to reconnect 10 times by default and then gives up.

npx webpack serve

2Fix

Start the server again and reload the page. To keep trying forever while you restart the server, raise the reconnect count.

export default {
  devServer: {
    client: { reconnect: true },
  },
};

3Verify

Stop and start the server; the page reconnects without a manual reload.

npx webpack serve

Confirmed by webpack.js.org

Did this fix it?

Cause 2 of 3

The page cannot reach the socket through a proxy or tunnel

1Check

The client script does not always know where to connect when the dev server is proxied. Compare the address in the browser with the dev server's real host and port.

grep -n -A6 "devServer" webpack.config.*

2Fix

Tell the client the socket address. Use the auto form to take protocol, hostname and port from the browser, or give each part yourself.

export default {
  devServer: {
    client: {
      webSocketURL: "auto://0.0.0.0:0/ws",
    },
  },
};

3Verify

Restart the dev server and watch the browser console stay quiet.

npx webpack serve

Confirmed by webpack.js.org

Did this fix it?

Cause 3 of 3

The host name you browse from is not allowed

1Check

allowedHosts is an allowlist of services allowed to reach the dev server. With 'auto' only localhost, the host option and the webSocketURL hostname are allowed.

grep -n -E "allowedHosts|host:" webpack.config.*

2Fix

Add your hostname (a leading dot matches subdomains) and set host if the server must be reachable from other machines. Avoid 'all'; it disables host checking and exposes you to DNS rebinding.

export default {
  devServer: {
    host: "0.0.0.0",
    allowedHosts: [".example.test"],
  },
};

3Verify

Restart and browse via that hostname.

npx webpack serve --host 0.0.0.0

Confirmed by webpack.js.org

Did this fix it?

How do I stop it coming back?

  • Set webSocketURL once in the config when you always develop behind a proxy or in a container.
  • Keep allowedHosts to named hosts and never use 'all' on a shared network.
  • Keep the dev server in its own terminal tab so a crash is visible.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.