phpvisual-studio-codegulpbrowser-sync

Gulp + BrowserSync proxy not loading


I have a PHP webserver on my machine that runs on port 5000.

I am trying to get a browserSync proxy with gulp to auto-refresh it, however it is not working without returning any error. I can access the page on port 5000, so the server is up, and I can access the browserSync UI, so the process for that is up as well.

Here is my gulp

function watch(){
    browserSync.init(null, {
        proxy: "0.0.0.0:5000",
        port: 5001,
        files: ['*.html', '**/*.css', '**.*.js', '**.*.php']
    });
    gulp.watch("src/**/*.php", reload);
}

And here is the console output from running it:

$ gulp watch
[02:51:57] Using gulpfile gulpfile.js
[02:51:57] Starting 'watch'...
[Browsersync] 1 file changed (index.css)
[Browsersync] 1 file changed (index.js)
[Browsersync] Proxying: http://localhost:5000
[Browsersync] Access URLs:
 --------------------------------------
       Local: http://localhost:5001
    External: http://192.168.128.1:5001
 --------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 --------------------------------------
[Browsersync] Watching files...

Don't know if it matters, but the webserver is a vscode extention: "PHP Server". I also already saw the similar questions but none of the answers worked, and I do not have malwareBytes installed.


Solution

  • Use 127.0.0.1 instead of localhost

    After reading somewhere (don't remember where) that localhost can cause problems, I changed the server settings to run off 127.0.0.1:5000 and the browserSync to proxy that and it worked