Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt message: Fatal error: Port 35729 is already in use by another process

Grunt was working. But after moving my site's files up one directory, to sit at root, grunt stopped working:

Fatal error: Port 35729 is already in use by another process.

Would the path matter in this case? Looking at port 35729, I found that Grunt was the only process running on that port. I killed that process, confirmed that no other process was running on 35729, then ran grunt again, but still getting that same fatal error as before.

Although none of my config files changed for grunt since it was working, I thought I'd try using the "npm init" approach to create a new package.json, then run "npm install" again and confirmed it downloaded "node_modules". What else can I try?

I'm running Node v0.10.33 on Mac OS 10.10.5

like image 418
Mark Salvatore Avatar asked Sep 02 '15 16:09

Mark Salvatore


3 Answers

Grunt watch was already running in a different project in my case. So I updated Grunt's watch task appropriately for live reload to watch on a different port.

 watch: {
        main: {
            options: {
                livereload: 35730,
                livereloadOnError: false,
                spawn: false
            },
            files: [createFolderGlobs(['*.js', '*.less', '*.html']), '!_SpecRunner.html', '!.grunt'],
            tasks: [] //all the tasks are run dynamically during the watch event handler
        }
    }

Specified livereload:PORT

like image 148
Venkat Kotra Avatar answered Nov 06 '22 01:11

Venkat Kotra


Dont stop a process with Ctrl+C in the terminal.

Ctrl+Z will keep it running.

Find the process id by sudo lsof -i :35729

Then kill the process by sudo kill -9 PID

Rerun the grunt watch

like image 34
Wasim Khan Avatar answered Nov 06 '22 02:11

Wasim Khan


The problem is grunt-contrib-watch's live reload: https://github.com/gruntjs/grunt-contrib-watch/blob/v1.0.0/tasks/lib/livereload.js#L19

You can't have two grunt-watch with the livereload option set to true. Either set one of the livereload options to false or change the port of liverelaod to something else by setting the livereload option from true to other value than 35729, like live-reload: 1337.

See the docs for more: https://github.com/gruntjs/grunt-contrib-watch#optionslivereload

Otherwise, you can run as many grunt processes as you want.

like image 3
Nicu Surdu Avatar answered Nov 06 '22 02:11

Nicu Surdu