0

I try to open my website on localhost using BrowserSync and Gulp in Chrome, but it doesn't work. Default, it open in Firefox and everything works well. But, when I change params in gulpfile.js to open website in Chrome - I have this information:

[Browsersync] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false) My config in gulpfile.js:

// browser-sync options
// see: https://www.browsersync.io/docs/options/
var browserSyncOptions = {
    browser: "google chrome",
    proxy: "localhost",
    notify: false
};

I tried "chrome", "chrome-browser", nothing happend. What I should to do? Notice: I have Ubuntu 17.04, Chrome is my default browser.

Marek
  • 117
  • 6
  • 14
  • Take a look at https://stackoverflow.com/questions/32171725/chrome-cant-open-localhost3000-with-gulp-browsersync?rq=1 – Mark Nov 22 '17 at 15:11

2 Answers2

3

I think the issue is with your port, try to change your proxy to below :

var browserSyncOptions = {
    browser: "google chrome",
    proxy: "localhost:3001",
    notify: false
};

and check your website in chrome with this port :

http://localhost:3001

Update :

Also try to use the same port in browserSync :

browserSync({ 
   proxy: 'localhost:3001' 
}); 
Emad Dehnavi
  • 3,262
  • 4
  • 19
  • 44
  • still this same information in console + website not loaded with 3001 port in url ;( – Marek Nov 22 '17 at 09:48
  • 1
    @Marek Try to add the same port to browserSync and try again, something like browserSync({ proxy: 'localhost:3001' }); – Emad Dehnavi Nov 22 '17 at 09:50
  • it doesn't work, not sync..but I if restart Apache, the default config (without browser: "google chrome") works...I don't know where was (is?) problem. Apache is changing port when restarting? – Marek Nov 22 '17 at 13:08
  • 1
    It can, find httpd.conf file and check for port there, if u use xamp it is usually in apache\conf\httpd.conf folder – Emad Dehnavi Nov 22 '17 at 13:12
  • For me, it only worked with: browser: "google-chrome", on Ubuntu 22.04. – Luís Assunção Feb 22 '23 at 10:51
1

Try dropping Google from browser sync call... var browserSyncOptions = { browser: "google chrome", proxy: "localhost:3001", notify: false };

So you just have chrome. var browserSyncOptions = { browser: "chrome", proxy: "localhost:3001", notify: false };

James Fooks
  • 69
  • 1
  • 7