gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Use 127.0.0.1 as default host instead of 0.0.0.0 #164

Closed fregante closed 9 years ago

fregante commented 9 years ago

0.0.0.0 is a reserved address, Google Chrome can't even connect to it at the moment.

Other packages are changing the default address to 127.0.0.1 too.

mzgoddard commented 9 years ago

0.0.0.0 is a reserved address and this is a correct usage of that address. 0.0.0.0 is an address to bind to not to connect to.

http://en.wikipedia.org/wiki/0.0.0.0

A way to specify "any IPv4 address at all". It is used in this way when configuring servers (i.e. when binding listening sockets). This is known to TCP programmers as INADDR_ANY. (bind(2) binds to addresses, not interfaces.)

A server bound to 0.0.0.0 can be accessed by 127.0.0.1 or any other ipv4 address assigned to network interfaces like ethernet and wireless chips. Chrome and other software shouldn't be able to connect to 0.0.0.0, for that you use any address that the system has mapped.

fregante commented 9 years ago

The problem therefore lays in the information given. If Chrome and other software shouldn't be able to connect to 0.0.0.0, then don't show 0.0.0.0 as the only option as it may confuse users who are not aware of this peculiar IP (like me until a few hours ago)

Why leave this burden on the end user when using 127.0.0.1 would suffice?

mzgoddard commented 9 years ago

Making an issue to have a small blerb explaining that 0.0.0.0 can be accessed from 127.0.0.1 or any other ipv4 for the system would be good. (Looking for a separate issue instead of repurposing this one since the intent is very different.)

The benefits of 0.0.0.0 outweigh 127.0.0.1 as a default. grunt-contrib-connect is intended to be used as a dev server, 127.0.0.1 means only the system hosting could access the server. 0.0.0.0 means things on the local network can access it too. That's really useful if you're working with a team and they are on your local network, either actually local or through a vpn. They can connect to your dev server to help debug problems or comment on visual changes. Its also useful for testing changes on other systems yourself through virtual machines, separate computers running a different OS, or mobile devices. 0.0.0.0 is the only address that maps to other network interfaces other than the 127.0.0.1 loopback. If you want someone or one of your devices to access your server 0.0.0.0 lets you without needing to change your configuration each time to set the right IP or have code to automate the lookup which can get complicated.

On Wed, Feb 18, 2015 at 12:09 PM, Federico Brigante < notifications@github.com> wrote:

The problem therefore lays in the information given. If Chrome and other software shouldn't be able to connect to 0.0.0.0, then don't show 0.0.0.0 as the only option as it may confuse users who are not aware of this peculiar IP (like me until a few hours ago)

First thing I did was to change it to 127.0.0.1 since 0.0.0.0 wouldn't connect. Why leave this burden on the end user when 127.0.0.1 would suffice?

— Reply to this email directly or view it on GitHub https://github.com/gruntjs/grunt-contrib-connect/issues/164#issuecomment-74903655 .