HMR/WDS client port ignored
See original GitHub issueI’m upgrading one of my projects from webpack v1.x to v2.x (most recent beta). My setup can be illustrated as follows:
Host OS +-------------------------------------------+
| Linux VM (VMWare) |
| |
+---------+ 9081 +-----+ 81 +-------+ 8080 +------------+ |
| Browser |------->| NAT |------>| nginx |------->| Webpack | |
| |<-------| |<------| |<-------| dev-server | |
+---------+ +-----+ +-------+ +------------+ |
| |
+-------------------------------------------+
I have webpack-dev-server running in my VM on port 8080 and nginx acting as a reverse proxy. As I want to test my app on my host OS, I have set up the VMware NAT-Utility Service to forward requests on port 9081 (host) to port 81 (VM).
With webpack v.1x I got HMR working by adding the entry point webpack-dev-server/client?http://0.0.0.0:9081 to my webpack-config. But this seems to break with Webpack v2.x. The browser’s output suggests that client?http://0.0.0.0:9081 just gets ignored as request are issued to port 8080.
[HMR] Waiting for update signal from WDS...
[WDS] Hot Module Replacement enabled.
GET http://localhost:8080/sockjs-node/info?t=1479759389108 net::ERR_CONNECTION_REFUSED
[WDS] Disconnected!
GET http://localhost:8080/sockjs-node/info?t=1479759392164 net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/sockjs-node/info?t=1479759396279 net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/sockjs-node/info?t=1479759405260 net::ERR_CONNECTION_REFUSED
I’m not sure if this is a bug or if I’m missing something…
Here is my webpack-config (webpack-dev-server --config webpack.config.debugHot.js). Here the relevant part of my ngnix config for completeness.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)

Top Related StackOverflow Question
Ah I think I understand the issue. Since webpack v2, inline mode is enabled by default if you use the CLI. This means that it automatically included the
webpack-devserver/clientscript. However, you also included that manually.The cleanest way to fix it is to remove
webpack-devserver/clientfrom your entry. There are two ways to make WDS listen to the correct domain:webpack-dev-server --public=0.0.0.0:9081devServerobject in your webpack config, addpublic:'0.0.0.0:9081'This solved my issue! Thanks a lot. Really appreciate your quick replies