13

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

Mark Salvatore
  • 628
  • 1
  • 7
  • 13

5 Answers5

35

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

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
Wasim Khan
  • 1,177
  • 12
  • 13
5

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

Venkat Kotra
  • 10,413
  • 3
  • 49
  • 53
3

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.

Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108
1

Problem solved. Although grunt-cli is installed globally, grunt gets installed locally with the project. So when I moved my site's files up one directory, and ran grunt from that new location, I was effectively launching a second instance of grunt, which found the port already occupied of course, by the earlier instance of grunt launched before moving files.

After I killed that process, grunt ran without a problem. I wasn't able to kill it using kill -9 so I used the Mac's Activity Monitor to issue "Force Quit".

Mark Salvatore
  • 628
  • 1
  • 7
  • 13
0

solution :

Step 1

Run command-line as an Administrator. Then run the below mention command. Type your port number in yourPortNumber:

netstat -ano | findstr : (yourPortNumber)

enter image description here

Step 2

Then you execute this command after identify the PID.

taskkill /PID  (typeyourPIDhere) /

Enjoy Coding !

ross
  • 2,684
  • 2
  • 13
  • 22
RAJ
  • 1
  • 2