jinglesthula
jinglesthula

Reputation: 4587

webpack-dev-server open and host opens wrong URL

Per the docs here and here, I have the following in my package.json

"scripts": {
  "start": "webpack-dev-server --host 0.0.0.0 --open",
  ...

With just --open it opens localhost:8080 when I run npm start. When I add in --host 0.0.0.0 it still opens, but opens 0.0.0.0:8080 and gives me ERR_EMPTY_RESPONSE in the browser. I can manually change it to localhost:8080 and it loads the page just fine.

I tried --host 0.0.0.0 --open --open-page localhost:8080 and it dutifully opens http://0.0.0.0:8080/localhost:8080 for me in the browser.

Has anyone gotten these two options to play nicely together?

Upvotes: 4

Views: 3052

Answers (1)

Tarun Lalwani
Tarun Lalwani

Reputation: 146630

Below works fine for me

webpack-dev-server -p --public 127.0.0.1:9000 --host 0.0.0.0 --port 9000

--host is the listening interface. --public is for what would be opened in the browser. And --open-page is for appending the page url after the main domain

Upvotes: 6

Related Questions