-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can BrowserSync live reload hosts browser if executed through guest VM? #318
Comments
I have a same question. |
It can even reload your browser if it's on a real remote server, so should work for VM too. |
@faergeek using the scenario I've described above I've been unable to get this to work. Is there perhaps a specific configuration I need? |
@gigablox when I installed it on remote server it didn't require any specific configuration. What exactly doesn't work for you? Does it create server for you which you can access through the browser or not? Please provide some info about your setup like described here https://github.com/shakyShane/browser-sync/blob/master/CONTRIBUTING.md#tips. |
@faergeek Confused about what additional details you would like me to provide. I thought my description of my setup was pretty thorough but I'll try again. I am using a virtual machine that executes browser sync. When I run browser sync on this virtual machine I am not trying to live reload the guest browser, but rather, the browser of the host machine that contains the guest machine. "Can BrowserSync live reload a hosts browser if it's being executed through the guest?" |
I used BrowserSync for testing in IE which runs in Virtual Box. I even used BrowserSync running on a remote server to connect through SFTP and edit files live. I didn't use it with virtual machine as a remote server but I think that may be virtual machine configuration is not working. So would be cool if you can provide additional details about your setup (may be some isolated config, using just BrowserSync and Vagrant) to try it out by myself and figure out what doesn't work for you. |
I still think there is a communication gap here. Imagine you just spun up a local VM on your development computer. That VM is running browser sync. I want browser sync to act on the hosts browser (the computer from which the VM is running)... |
@gigablox - How about providing a simple vagrant setup for us as @faergeek suggested. That way we all know what we're talking about. Unfortunately "Imagine you just spun up a local VM on your development computer" is not really enough info for us to go on, even if the whole thing seems extremely simple to you. :) |
To answer your original question: yes, browserSync can live reload hosts browser if executed through a guest VM. I am running an Ubuntu 14.04 guest (VMWare fusion) on my host (Mac OS X) machine. All my (web) development is done on the Ubuntu guest and the guest is also running BrowserSync (using gulp). I use my host browser to visit the browser-sync served project. I "had" the same problem last night, hence I found this thread. But was able to solve it this morning simply by altering my (gulp) configuration. I originally ran both my watch task and BrowserSync task separately, however once combined BrowserSync on my host browser was working. |
@HPieters Awesome, do you mind sharing the important parts of that config? |
@gigablox my config can be found here https://gist.github.com/HPieters/88dd18e99c8925b2cabb. Hopefully it is useful, as far as I can see it is the default way of setting up BrowserSync. |
Hello I think I have the same issue. I launched Brwosersync in my VM and I want to test my app in my host machine. This is my grunt task configuration for browsersync :
Wen launching Browsersync, I have the following input in my console :
My question is : Why is the host 'localhost' ??? The result is that I cannot open my app in my host machine since I don't know what URL to open. Best regards |
I think you should find you VM IP address,then open The IP address in you host browser, such as |
Hello I've tried but therer is no syncing and no live reload :( |
Probably depends on how the VM's network is set up. Maybe you need to forward the ports. (3000, 3001) |
@gigablox did you get this working? I agree with your earlier comment that there's a communication gap on this thread and I'm encountering the same issue running browserSync inside a Vagrant box. |
Works for me under Vagrant + VirtualBox: I have a browser on my host machine connecting to the page served from within the VM and it refreshes as expected. The only port forwarding set up in my Vagrantfile is the port serving the pages via browsersync; which suggests to me that if you can see the pages on your host machine browsersync should be updating; so you might need to look for other causes... At first it wasn't working for me; but I eventually discovered that this was because of a separate issue. |
@faergeek could you elaborate on what you did? I'm also interested in doing something similar using the command line |
@karneaud now I see that if you're trying to accomplish this using just CLI, it doesn't work: browser-sync's watcher doesn't detect changes synced through Vagrant, but detects changes made through VM itself. So, if you want to run project on guest and edit sources on host it won't work. It looks strange, because gulp and stylus watchers are working normally. |
As a temporary workaround for that issue you can add module.exports = {
"files": '**/*',
"watchOptions": {
usePolling: true
},
"server": true
}; And start browser-sync like this: browser-sync start --config bs-config.js Now watcher should work. |
thanks for that @faergeek :) |
If I'd only noticed that exact issue earlier... :) |
@blindfish3 you are running browser-sync from within the vagrant box correct? If so, I would love to see your config :). |
Thanks @faergeek the polling option worked for me. Why is this temporary though? Is this a performance issue? I use Webpack in another VM and they use polling to fix this issue. My understanding is this is happening because Virtual Box only syncs files from Host to Guest and not the other way round. So when you edit files in your text editor nothing will happen but if you edit them through the command line inside your Vagrant box then Browsersync should work as normal. This is my setup that's working now, notice I'm only watching the source files rather than everything otherwise you'll get stuck in a loop.
|
I am still facing the same issue. Cant view the UI port or use browser-sync in host machine. i have 3000, 3001 forwarded from VM to host but no use. |
Maybe same problem here. Can't get this to work: Setup: local (Mac) Machine (Browser) <--- VPN ---> Debian VM (running browsersync) |
@regenrek yes, i am facing the same problem as well. |
Thank you @faergeek! I've mentioned your solution: http://bit.ly/2dPl5eZ |
@dokker You're welcome :-) @samsfisher @regenrek does this ^^ solve your problem? |
@faergeek
Now http://wpdev2:3000 worked via VPN/Local Network to the VM:
Since I used webpack2 with browsersync (or at least tried it) and it was pretty slow I changed back to webpack 1 and browsersync works fine now and even better and faster then before. And the polling options didn't help me. End of the story. Regards |
Hello In my case the watchOptions is helping me to refresh webpack build whenever On October 14, 2016 at 9:39:41 AM, Sergey Slipchenko (
|
|
express.js
I can see that browserysnc is initializing but its not working through VM. Also my ports are open from 3000 to 3002. |
@faergeek to add the port forward in vagrant is configured as well |
@samsfisher You've added |
@samfisher proxying should be meanstack.dev:3000 i think. Thats the problem |
Tried that as well. Fyi..i am using generator angular fullstack build |
@samsfisher what should browser-sync do for you? Reload css? Sync events? I think it would be better to run browser-sync and webpack separately and just include browser-sync script onto the page (not running browser-sync's web server). Proxying is always problematic. |
I'm running an issue where browserSync fails to open the browser. This only started happening when I changed my synced folder from being a symlink to being a mounted with |
Just in case anyone has a similar issue here is how I set up browser-sync (it was for Drupal 8 with Radix). First I opened up the necessary ports by going to the settings -> network -> adaptor 1 (attached to NAT) -> port forwarding and open up the necessary ports, in my case 3002, 3003 Second I set up my hosts file on my guest machine (windows) to point to the IP of the VM (in my case 192.168.0.41 and the host name samplesite.devserver.com) What I had failed to do when I had the issue is also set this up on the guest machine (Debian) by entering it into the hosts file in /etc/ After this I ran gulp (setting the proxy to samplesite.devserver.com) and it all worked fine. "proxy" : "bizhive.devserver.com", Hope it helps someone. |
I put together a simple example that uses gulp, Scotch Box, and the solution from @faergeek. It adds |
Forwarding browser-sync ports in Vagrantfile is the only solution for me, and had to manually open localhost:3000. For file watching, I have separate independent gulp tasks that are passed into the browser-sync task and watched. |
Hi! I am new to Vagrant and Gulp! I followed the instructions to setup the Homestead box, Gulp and Browser Sync. I did not have to do a quite complicated configuration to make it work. However, I realized that I could make it work just by attaching the :3000, at the end of the URL of my local website. Like "homestead.app:3000". That worked to me! I was getting the error "Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false)" after running the "gulp" command from within my VM. Then, I open the browser, Chrome, in my host and pointer the address to "homestead.app:3000". |
I have an Ubuntu 14.04 host and a Vagrant Ubuntu 14.04 Server Virtual Machine via Virtual Box.
I want to keep development tools like NPM's on the VM. One of those tools are BrowserSync.
Can BrowserSync live reload a hosts browser if it's being executed through the guest?
http://stackoverflow.com/questions/26683099/can-browsersync-live-reload-hosts-browser-if-its-being-executed-through-guest-v
The text was updated successfully, but these errors were encountered: