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']);
}
If you want to terminate the process using the port, you can do the following:
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
and now running
grunt
should work just fine :)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.
Add
to the page you want livereload on. 1337 being the port you set it to in the grunt file.
You can manually shutdown the livereload server in a bash/terminal window like so:
More info here: https://github.com/mklabs/tiny-lr
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.