After browserSync is enabled once, what should I do if I turn it on and repeat the port number?

I started the server with browserSync. I already started a server with a port number of 3000. When I started the second server, I was prompted to repeat the port number.
this is the server that has been turned on:

clipboard.png

:

clipboard.png

I used to remember that 3002 port numbers were automatically generated, but now I always report errors. I don"t know why.

here is my code for using browserSync:

var gulp = require("gulp"); //gulp
var less = require("gulp-less");
var prefix=require("gulp-autoprefixer");
var browserSync = require("browser-sync").create();
// var postcss = require("gulp-postcss");
var reload=browserSync.reload;

gulp.task("browserSync",["less"],function() {
    browserSync.init({
        server:"dist"
    });
    gulp.watch("src/less/*.less", ["less"]);
    gulp.watch("dist/*.html").on("change", reload);
    gulp.watch("dist/js/*.js").on("change", reload);
});

function handleError(err) {
    console.log(err.toString());
    this.emit("end");
}

//testLess
gulp.task("less", function () {
    return gulp.src(["src/less/**/*.less","!src/less/reuseClass.less"]) //
        .pipe(less()).on("error", handleError)
        .pipe(prefix({
            "browsers":"last 10 version"
        })).on("error", handleError)
        // .pipe(postcss(processors))
        .pipe(gulp.dest("dist/css/"))
        .pipe(reload({stream: true}));
    console.log("less",new Date().getTime());
});

turn off the node process in the process and start it successfully on restart. The direct restart fails because the port is occupied.

Menu