Skip to content

Listen only on host IP - #1431

Closed
n9 wants to merge 1 commit into
BrowserSync:masterfrom
n9:#1132
Closed

Listen only on host IP#1431
n9 wants to merge 1 commit into
BrowserSync:masterfrom
n9:#1132

Conversation

@n9

@n9 n9 commented Sep 21, 2017

Copy link
Copy Markdown

Hacked solution for #1132.

@shakyShane

Copy link
Copy Markdown
Contributor

@n9 please try the following

npm i -g browser-sync@2.25.0-alpha.0
browser-sync . --listen localhost

For backwards compatibility reasons, we actually cannot use the host option to acheive this, as it would break some people's existing setups.

This is mainly because in the past, host was not used (as you point out) to determine an address to bind to, but rather just as a way of changing the urls Browsersync displays to the user.

It was a big mistake, but now with the user base we have, every tiny change to any existing option causes some kind of breakage. I'm not prepared to do that again with host.

So, instead we're back to the old method of instead adding a new option, that I've called 'listen'. It's the only way we can acheive the goal without breaking existing users who are using host for other reasons.

The idea is that you'd only ever use the 'listen' option if you want to restrict the address being bound to - it will have the same effect as what was seen in the PR, but there turned out to be a lot more code to change.

So, to anyone that would like to see this option land in stable, can you call try version browser-sync@2.25.0-alpha.0 with the listen option set to some domain. (like localhost, or 127.0.0.1)

If I can get some feedback on whether it solves this problem, I'm happy to land it.

Thanks :)

@shakyShane

Copy link
Copy Markdown
Contributor

Fixed with the new 'listen' option

npm i -g browser-sync@2.25.0
browser-sync . --listen localhost

@shakyShane shakyShane closed this Oct 6, 2018
@n9

n9 commented Nov 8, 2018

Copy link
Copy Markdown
Author

@shakyShane It listens on given IP address, however the free port detection seems broken. I want browser-sync to listen on 127.0.33.1 port 80. Port 80 is already used with 127.0.0.1. Browser-sync correctly listens on 127.0.33.1, however on port 81 instead.

@btjanaka

btjanaka commented Oct 5, 2020

Copy link
Copy Markdown

Was this feature (--listen) ever documented? It does not show up here: https://www.browsersync.io/docs/options, but when I add listen: localhost in my BrowserSync config, it seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants