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

5

10

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']);

}

Kyser answered 9/10, 2013 at 9:31 Comment(0)
C
7

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
},
Catafalque answered 3/1, 2014 at 20:31 Comment(0)
P
6

You can manually shutdown the livereload server in a bash/terminal window like so:

curl localhost:35279/kill

More info here: https://github.com/mklabs/tiny-lr

Potemkin answered 1/2, 2014 at 8:7 Comment(2)
curl: (7) Failed to connect to localhost port 35279: Connection refusedHaemorrhage
Is it possible you meant for it to be port 35729 which is the default port for livereload?Upkeep
R
3

Are you using the Sublime Text and the LiveReload package? It's been known to cause this issue. If so, disable or uninstall the package in Sublime Text.

Ragout answered 29/10, 2013 at 22:3 Comment(0)
I
1

I use grunt on a vagrant VM so i need grunt to run on port 80, first i'll stop apache and start grunt serve and it works just fine.

Sometimes, however, grunt for some reason won't release the port after being stopped. For example: i usually stop grunt to edit the Gruntfile.js and start it again, but sometimes it won't start and will complain about someone using the por 80.

The only solution that has worked for me is to restart your shell session and try again.

I use ZSH and i noticed that after grunt breaks if i try to exit the shell ZSH complains about 'pending jobs', but if i exit anyways and restart the session and try grunt serve again it will work.

Insufficient answered 28/9, 2015 at 17:21 Comment(0)
C
1

If you want to terminate the process using the port, you can do the following:

$ lsof -n -i4TCP:35729
COMMAND   PID      USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node    15723  testuser   24u  IPv6 0x71823b3990749ea5      0t0  TCP *:35729 (LISTEN)

Now you have the PID of the process that's listening on the port you're trying to access, so you can kill this with

$ kill -9 15723

and now running grunt should work just fine :)

Chaffinch answered 2/12, 2015 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.