Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grunt Server "Got error listen EADDRINUSE" #938

Closed
rememberlenny opened this issue Feb 21, 2013 · 35 comments

Comments

@rememberlenny
Copy link

commented Feb 21, 2013

Followed instructions for basic webapp and can't get the server running.

Started with yo webapp, but getting an error every time I run grunt server.

Error:

Running "server" task

Running "clean:server" (clean) task

Running "coffee:dist" (coffee) task
>> Destination not written because compiled files were empty.

Running "compass:server" (compass) task
Nothing to compile. If you're trying to start a new project, you have left off the directory argument.
Run "compass -h" to get help.

Running "livereload-start" task
... Starting Livereload server on 35729 ...

... Uhoh. Got error listen EADDRINUSE ...
Error: listen EADDRINUSE
    at errnoException (net.js:769:11)
    at Server._listen2 (net.js:909:14)
    at listen (net.js:936:10)
    at Server.listen (net.js:985:5)
    at Server.listen (/Users/lkbogdonoff/sites/portfolio/node_modules/grunt-contrib-livereload/node_modules/tiny-lr/lib/server.js:133:15)
    at Object.startLRServer (/Users/lkbogdonoff/sites/portfolio/node_modules/grunt-contrib-livereload/lib/utils.js:21:11)
    at Object.module.exports (/Users/lkbogdonoff/sites/portfolio/node_modules/grunt-contrib-livereload/tasks/livereload.js:44:20)
    at Object.task.registerTask.thisTask.fn (/Users/lkbogdonoff/sites/portfolio/node_modules/grunt/lib/grunt/task.js:78:16)
    at Object.Task.start._running (/Users/lkbogdonoff/sites/portfolio/node_modules/grunt/lib/util/task.js:282:30)
    at Task.runTaskFn (/Users/lkbogdonoff/sites/portfolio/node_modules/grunt/lib/util/task.js:235:24)```

Any thoughts @sindresorhus ?
@jaromero

This comment has been minimized.

Copy link

commented Feb 21, 2013

I am currently having the same issue, except that mine is from attempting to run servers for two different projects (and thus the livereload server from the first one is able to grab and hold on to port 35729; the second one therefore fails with EADDRINUSE).

It's relatively straightforward to edit the port in the connect:livereload task in Gruntfile.js, but I have absolutely no clue how to specify the LR server port here. (The task that sets up the LR server is called livereload-start with the dash, and trying to add it in camel case to Gruntfile.js apparently has no effect).

EDIT: livereload-start, not -server

@rememberlenny

This comment has been minimized.

Copy link
Author

commented Feb 21, 2013

I noticed that my xcode and command line tools were not up to date.
Currently in the process to fix it.

The problem with removing the livereload lines from Grunt are that you cant
run Grunt server.

On Thu, Feb 21, 2013 at 2:12 PM, Antonio Romero notifications@github.comwrote:

I am currently having the same issue, except that mine is from attempting
to run servers for two different projects (and thus the livereload server
from the first one is able to grab and hold on to port 35729; the second
one therefore fails with EADDRINUSE).

It's relatively straightforward to edit the port in the connect:livereloadtask in Gruntfile.js, but I have absolutely no clue how to specify the LR
server port here. (The task that sets up the LR server is called
livereload-server with the dash, and trying to add it in camel case to
Gruntfile.js apparently has no effect).


Reply to this email directly or view it on GitHubhttps://github.com//issues/938#issuecomment-13906870.

Leonard Bogdonoff
lkb.cc http://www.lkb.cc/ / @lkbcc http://twitter.com/lkbcc
949-322-8496

@sindresorhus

This comment has been minimized.

Copy link
Member

commented Feb 21, 2013

@lkbgift It means the port is in use. Make sure you're not running the server in another terminal. Otherwise, just change the port in the Gruntfile.

@sleeper Can you catch Got error listen EADDRINUSE and show a more userfriendly error?

@jaromero

This comment has been minimized.

Copy link

commented Feb 21, 2013

@sindresorhus it's not very clear how to change the port livereload uses. I had to dig into grunt-contrib-livereload/lib/utils.js:13 to figure it out. Turns out the port can be overridden directly in the livereload task, not inside the options property which confused the hell out of me at first:

// ...
livereload: {
    port: 35728
}
// ...

This does NOT work:

// ...
livereload: {
    options: {
        port: 35728
    }
}
// ...

Perhaps an issue to report at gruntjs/grunt-contrib-livereload?

@sindresorhus

This comment has been minimized.

Copy link
Member

commented Feb 21, 2013

Perhaps an issue to report at gruntjs/grunt-contrib-livereload?

Sure.

@jaromero

This comment has been minimized.

Copy link

commented Feb 22, 2013

On second thought, I don't even think it's necessary to change anything, if the purpose of having livereload in the first place is to just aid in testing. So naturally it really only should run for the server target (no need for target-specific options really) and in no other circumstance unless you explicitely modify the tasks set up by yo (by which point I guess we can assume you know what you're doing).

If anything, it should probably go into the yeoman docs, for people wanting to run more than one server like this.

Incidentally, I'm not even sure if this is the same issue as @lkbgift had (and/or if it was solved), so I apologize if I accidentally hijacked this issue. I'll create a new issue if that's the case.

@rememberlenny

This comment has been minimized.

Copy link
Author

commented Mar 1, 2013

@jaromero no worries! Our problems are different, but in any case I figured it out.

I documented by stop-gap fix here: http://lkb.cc/blog/2013/03/01/yeoman-eaddrinuse-error-fix/

Hopefully if someone searches for the same problem, they can emulate my change or find this thread.

@Sinetheta

This comment has been minimized.

Copy link

commented Mar 1, 2013

I have the same issue, and had to get around it in the same way (by disabling livereload). Would be nice to find a fix though, no amount of specifying the port option seems to actually change anything.

@krzysztofantczak

This comment has been minimized.

Copy link

commented Mar 7, 2013

@lkbgift just change it's port, and it should work again, but as @jaromero said, livereload reads 'port' option from another place, than You think looking at your Gruntfile (confirmed by watching grunt livereload sourcecode).

@Melindrea

This comment has been minimized.

Copy link

commented Mar 9, 2013

And whether or not this is the same issue others had, I today realised the reason I was getting that error is because I was working in Sublime Text 2, with the LiveReload plugin active, so although this doesn't have anything to do with Yeoman, it might be a useful thing for people googling the error message.

@rememberlenny

This comment has been minimized.

Copy link
Author

commented Mar 9, 2013

Ah that is exactly my situation too!!!

Tha should be an faq point.

Thank you soooo much.

On Mar 9, 2013, at 12:58 s lPM, Marie Hogebrandt notifications@github.com wrote:

And whether or not this is the same issue others had, I today realised the reason I was getting that error is because I was working in Sublime Text 2, with the LiveReload plugin active, so although this doesn't have anything to do with Yeoman, it might be a useful thing for people googling the error message.


Reply to this email directly or view it on GitHub.

@swallentin

This comment has been minimized.

Copy link

commented Mar 25, 2013

Hi,

My finding is that there is a conflict between LiveReload Mac OS X App and the grunt-contrib-livereload package.

If you have the LiveReload App running issuing $ grunt server will fail and vice versa. To circumvent this issue, close down the LiveReload App while using the grunt-contrib-livereload plugin (which seems to be included by default when using yeoman).

When you have LiveReload App running you will get this,
LiveReloa 7519 stephanwallentin 7u IPv4 0x4734c35ddd807ff3 0t0 TCP *:35729 (LISTEN)

When you run $ grunt server from your project folder you will get this,
node 7547 stephanwallentin 8u IPv4 0x4734c35ddd807ff3 0t0 TCP *:35729 (LISTEN)

@swallentin

This comment has been minimized.

Copy link

commented Mar 29, 2013

Hi again,

Stated earlier there is an easy solution to this problem, changing the port number in the config file.

I added this to my Gruntfile.js,

    yeoman: yeomanConfig,
    livereload: {
      port: 35728
    }

A suggestion is to add livereload config port for the default webapp gruntfile. This can clarify for other developers running into this problem.

@chandlervdw

This comment has been minimized.

Copy link

commented Apr 5, 2013

Unless I'm mistaken, this issue is present in generator-angular, as well.

@passy

This comment has been minimized.

Copy link
Member

commented Apr 5, 2013

@chandlervdw It's not an issue in any particular generator, it just happens if you have another process blocking the port.

@atomless

This comment has been minimized.

Copy link

commented Apr 8, 2013

Just like to confirm that removing the LiveReload package in Sublime Text 2 fixes this issue :- using Package Control: Remove Package, then choose LiveReload and after a sublime restart grunt server now works on the cli without error.

@chandlervdw

This comment has been minimized.

Copy link

commented Apr 8, 2013

@iDVB

This comment has been minimized.

Copy link

commented Apr 10, 2013

Removing LiveReload does not seem to take care of the issue for me. I've verified it is indeed removed. However, the only thing that works is to close Sublime Text 2 all together. Anyone else have this persistant of an issue?

UPDATE - Turns out that removing the subl livereload DID fix the issue. I was at that point having the issue that even though I had broke out of the previous "grunt server" call, it was still running in the background so when I tried to run it again it was now that that was erroring. In short, I killed my term window as well and all is now well.

Thanks!

@rememberlenny

This comment has been minimized.

Copy link
Author

commented Apr 10, 2013

@iDVB Can you open Activity Monitor and search for the livereload ports? You might have another application running as a plugin without realizing it.

@alepee

This comment has been minimized.

Copy link

commented May 3, 2013

@atomless +1
I disabled LiveReload in ST2, like a boss ;)

@rowild

This comment has been minimized.

Copy link

commented May 5, 2013

I can confirm that the deactivation of the liveReload plugin in Sublime Text 2 fixes the problem.

@goliatone

This comment has been minimized.

Copy link

commented May 12, 2013

I don't feel disabling ST2 LiveReload plugin is a real fix. Like @swallentin suggested, just add a new line in the config to set a new port.

yeoman: yeomanConfig,
    livereload: {
      port: 35728
    }

The real issue thou, is that instinctively you want to add the option to connect.livereload.options
Anyhow, it seems that grunt-contrib-livereload will be deprecated.

Live reloading is now built into grunt-contrib-watch version 0.4.0. grunt-contrib-livereload and grunt-regarde will be deprecated soon.

@sindresorhus

This comment has been minimized.

Copy link
Member

commented May 13, 2013

@goliatone the real issue is ST2 LiveReload. Though it's easy enough work around it by changing the port.

@angsmith

This comment has been minimized.

Copy link

commented May 15, 2013

@sindresorhus I have the same issue and LiveReload is disabled in ST2 for me.

@rememberlenny

This comment has been minimized.

Copy link
Author

commented May 16, 2013

Look at your activity monitor to see whether the livereload port is being occupied.

Leonard Bogdonoff
@Lkbcc | 949-322-8496

On Wed, May 15, 2013 at 7:49 PM, asmith notifications@github.com wrote:

@sindresorhus I have the same issue and LiveReload is disabled in ST2 for me.

Reply to this email directly or view it on GitHub:
#938 (comment)

@angsmith

This comment has been minimized.

Copy link

commented May 16, 2013

I fixed it by adding the port into the config (as per @goliatone comment above), however just wanted to state for anyone new to this thread that it's not just Sublime Text 2 that causes the issue.

@sindresorhus

This comment has been minimized.

Copy link
Member

commented May 16, 2013

@angelasm1th that's true, the Livereload browser extension can also cause it.

@ghost

This comment has been minimized.

Copy link

commented May 18, 2013

In my case I simply already had a 'grunt server' running in a different screen. After ending the other grunt server I was able to start a new one without the above error.

@estace

This comment has been minimized.

Copy link

commented Nov 8, 2013

To kill the processes being used by that port, type in your terminal:

kill -9 $(lsof -t -i :9000)

(be sure to update the port number to correspond to your project)

@eilvein

This comment has been minimized.

Copy link

commented Aug 19, 2014

delete sublime livereload Or shut down sublime

@purish

This comment has been minimized.

Copy link

commented Nov 25, 2014

i dont know whether the issue of 'listen EADDRNOTAVAIL' is the same with you

@monolithed

This comment has been minimized.

Copy link

commented Feb 25, 2015

+1

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1129:14)
    at listen (net.js:1155:10)
    at net.js:1253:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:81:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:99:10)
@basilinjoe

This comment has been minimized.

Copy link

commented Aug 21, 2015

hay am getting this error ! help me please !

error: Grunt :: Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Agent.Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Agent.Server.listen (net.js:1267:5)
at Object.start (_debugger_agent.js:20:9)
at startup (node.js:86:9)
at node.js:814:3

@akhayoon

This comment has been minimized.

Copy link

commented Dec 24, 2015

Thanks @estace your solution did it for me. Just killed the port and everything worked again.

@rajanmidd

This comment has been minimized.

Copy link

commented Jan 9, 2018

Hey,

I am using grunt cli with npm. I have some number of packages but there is one package named as java from npm (https://www.npmjs.com/package/java).

When java npm package is installed then grunt is not able to restart the node server on change in file.

So can you please let me know what is the issue of grunt with java npm package or how can I solve this?

I got this error:Error: listen EADDRINUSE" on change in any file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.