The webpack dev server client reports it is disconnected and stops reloading
[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.
Fix it fast
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:80802Match what you see, then jump to its fix
- 1
The terminal shows a crash, or the process is gone; the page keeps the old contentThe dev server process stopped or restartedFix - 2
The 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
Opening the app by a LAN name or a custom domain works but live reload is deadThe host name you browse from is not allowedFix
- 1
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 serve2Fix
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 serveConfirmed by webpack.js.org
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 serveConfirmed by webpack.js.org
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.0Confirmed by webpack.js.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix