grunt watch livereload Fatal error: Port 35279 is already in use by another process

user2808895 picture user2808895 · Oct 9, 2013 · Viewed 7.6k times · Source

I'm trying to use livereload with watch. I keep getting the message "Fatal error: Port 35279 is already in use by another process" . I've changed the port for livereload but then nothing reloads.

module.exports = function(grunt) {
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    compass: {
      dist: {
        options: {
          cssDir: 'stylesheets',
          sassDir: 'stylesheets/sass/',
          imagesDir: 'images',
          javascriptsDir: 'scripts',
          require: ['sass-globbing','modular-scale'],
          force: true
        }
      }
    },
    cssmin: {
      minify: {
        expand: true,
        cwd: 'stylesheets',
        src: ['*.css', '!*.min.css'],
        dest: 'stylesheets',
        ext: '.min.css'
      }
    },
    watch: {
        options: {
            livereload: true
        },
        sass: {
            files: 'stylesheets/sass/*.scss',
            tasks: ['compass']
        },
        css: {
            files: 'stylesheets/*.css',
            tasks: ['cssmin']
        },
        html: {
            files: ['index.html','**/*.css']
        }
    }
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default',['compass','watch']);

}

Answer

xphong picture xphong · Jan 3, 2014

Add

 <script src="//localhost:1337/livereload.js"></script>

to the page you want livereload on. 1337 being the port you set it to in the grunt file.

options: {
        livereload: 1337
},