webpack-dev-server: Server can't be accessed via IP
In 1.7.0 the following command:
webpack-dev-server --port 3000 --hot
would allow the server to be accessed at:
http://localhost:3000 and
http://10.0.1.4:3000 (my local IP).
In 1.8.0 accessing http://10.0.1.4:3000 no longer works.
Not sure if this has to do with webpack-dev-server or one of the dependencies.
I’m using node 0.12.2 and running OSX 10.10.2
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 44
- Comments: 31
Links to this issue
Commits related to this issue
- 解决 webpack-dev-server 无法通过 ip 访问 BUG https://github.com/webpack/webpack-dev-server/issues/147 — committed to zaxlct/webpack-dev-boilerplate by zaxlct 8 years ago
- [CSE-124] Fix port issues with VM Webpack does not support to access `localhost` of `devServer` from a VM. Solution is described here: https://github.com/webpack/webpack-dev-server/issues/147#issueco... — committed to input-output-hk/cardano-sl-explorer by sectore 7 years ago
- Exposed host in JS WebPack config By allowing "host" to be specified for the DevServer of a WebPack config, it can be set to "0.0.0.0" to allow access from other computers on the network. See, for ex... — committed to Labdabeta/kotlin by Labdabeta 4 years ago
1.8.0 appears to be defaulting to "localhost’ now. You can open it up by passing the --host option.
webpack-dev-server --port 3000 --hot --host 0.0.0.0It can also be set from the webpack file by setting
devServer.hostto0.0.0.0.the hardcoded IP wouldn’t work for me @peacechen - I was able to get mine to work by disabling
disableHostCheck. eg.If you’re using WebpackDevServer, be aware that the host argument is part of
server.listenas follows:I had to do the following to get mine to work with the help from @pdillon and his comment
I have Windows 7 so I did
Then went up to LAN and found the ipv4 address Mine was
So I edited my npm run start command to be
I was then able to access the content that is being served on
Will be available as the web on another computer by going to
In the web browsers URL field on the other computer that was connected to the same wifi network
oh my god
I turn on the
openswitch, then the browser will open ‘http://0.0.0.0:8080/’. But 0.0.0.0 is not accessible.just FYI, you can just type
0instead of0.0.0.0for ease of use 😃Using
host: '0.0.0.0'in the devServer section of webpack.config does allow the server to be seen by peers on the LAN, but iOS Safari complains with “Invalid Host header”. The only way to get Safari to load is to hard code the IP 😦@anchengjian Use
public: 'http://localhost:' + PORT,if you want to keep auto open usingopen: trueand dont want to end up with 0.0.0.0 in browser, which is unreachable.Ahh. Good to know. Thanks!
Perhaps it’s worth to point out that in order to access the webpack-dev-server from other devices on your local network you need to pass
--public your-host:portsince version 2.4.3.See https://github.com/webpack/webpack-dev-server/issues/882.
Maybe add this to the top of this thread if possible?
For anyone who are using vue webpack template, this issue can be solved by config the
config/index.js, find the config ofhostthen change the value to0.0.0.0, like below:@anchengjian Here are some piece code of my server.js
In listen function ,the second param set ‘0.0.0.0’ , maybe can solve this problom.
Thanks @pdillon, just got gatsby
1.1.11to work with:Is there a way to dynamically generate the
--hostIP address in thepackage.jsonfile or with a setting inwebpack.config.js? I am currently using0.0.0.0, but it has been suggested that this is insecure.@erikyuzwa thanks
How did I use express to do?
It didn’t work!