gulp-community/gulp-livereload

Got error listen EADDRINUSE

rodrigoea opened this issue ยท 27 comments

I'm trying to solve a problem in a repository that uses gulp-livereload.

A few days ago I'm getting this error:

... Uhoh. Got error listen EADDRINUSE ...
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at Server.listen (/Applications/MAMP/htdocs/conferencia-orlando/site/node_modules/gulp-livereload/node_modules/tiny-lr/lib/server.js:138:15)
at Function.exports.listen (/Applications/MAMP/htdocs/conferencia-orlando/site/node_modules/gulp-livereload/gulp-livereload.js:68:12)
at Function.exports.changed (/Applications/MAMP/htdocs/conferencia-orlando/site/node_modules/gulp-livereload/gulp-livereload.js:88:20)
at Transform.reload._transform (/Applications/MAMP/htdocs/conferencia-orlando/site/node_modules/gulp-livereload/gulp-livereload.js:24:13)
at Transform._read (_stream_transform.js:179:10)
at Transform._write (_stream_transform.js:167:12)

Here is the gulpfile.js:
https://github.com/samwx/html-skeleton-gulp/blob/master/gulpfile.js

How can I solve? Thanks.

You're probably trying to use a port that is already in use. Livereload listens on port 35729 to communicate with browser extensions; try killing other instances of gulp/livereload and see if the issue persists.

Yes, I'm running just one instance of gulp/livereload, the issue persists :(

Perhaps you're running the OS X livereload app? Or the livereload ST2/ST3 extension?

Try changing the port number on line 91 of your gulpfile to something other than 35729

I uninstalled Livereload app (even if not open, I kept getting the error). I haven't ST extension.
captura de tela 2014-07-03 as 23 16 54

I have the same problem currently and a similar livereload setup (with passing an own tiny-lr server into it). I guess it has something to do with that but I'm not yet sure.

I'm still trying to solve it. I've tried to update node but was unsuccessful.

Try adding {auto: false} on each livereload(server) call.

Like this? .pipe(livereload(server, {auto: false}));. Didn't work.

Have you found a fix for this yet? I am having the same problem.

[gulp] Starting 'watch'...
[gulp] Finished 'watch' after 2.83 ms

... Uhoh. Got error listen EADDRINUSE ...
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at Server.listen (/Users/Hail/dev/zoerooney/the-larson-house/node_modules/tiny-lr/lib/server.js:145:15)
at Gulp. (/Users/Hail/dev/zoerooney/the-larson-house/gulpfile.js:42:10)
at module.exports (/Users/Hail/dev/zoerooney/the-larson-house/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:33:7)
at Gulp.Orchestrator._runTask (/Users/Hail/dev/zoerooney/the-larson-house/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/Hail/dev/zoerooney/the-larson-house/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/Hail/dev/zoerooney/the-larson-house/node_modules/gulp/node_modules/orchestrator/index.js:134:8)

I didn't realize that I had another terminal window open and running gulp watch in the background. Double check that, just in case.

@rodrigoantinarelli - You have a separate instance of tiny-lr running in your gulpfile - tiny-lr is a dependency of gulp-livereload, so your port conflict is on 35729. Changing the port number on line 91 of your gulpfile fixes this, as I said last month. See this section of the readme for reference. I'd recommend reworking your gulpfile to reflect the current examples in the readme, and removing the additional tiny-lr dependency.

@bradcerasani but gulp-livereload supports the option to use an already existing server. Shouldn't it be no problem then? Otherwise some conditionals might be wrong, no?

@mweibel Right, but an existing server can't be on the same port you're trying to use with gulp-livereload or you'll see EADDRINUSE. You can pass an options object with auto: false to stop gulp-livereload from starting another tiny-lr server as you recommended earlier - @rodrigoantinarelli I tried this on your repo and it eliminated the error for me?

I tried to change the port 35729. The error EADDINUSE no longer appears, but livereload (the browser reload) still not working.
@bradcerasani the error has been eliminated, but the browser reload worked properly?

Yes. I just submitted a pull request to the repo you were referencing. Try this fork and let me know if it works for you: https://github.com/bradcerasani/html-skeleton-gulp

Oh, very nice! It worked fine. Thank you for your help! \o/

Good to hear :)

@bradcerasani I had a Grunt watch running that I'd forgotten about that also used Livereload. Turned it off and BAM! High five for that answer!
colbert high five

i got it to work but when i go to localhost:8088 it just prints "{"tinylr":"Welcome","version":"0.1.5"}"

had this issue and it was my sublime livereload extension. uninstalled the extension, re-ran gulp watch and that solved it

events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at EventEmitter.listen (/home/nikita/smart-car-node/node_modules/express/lib/application.js:617:24)
at Object. (/home/nikita/smart-car-node/app.js:40:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

how to solve? new to node

@nikitabanthiya It means another process is using the port. You need to stop all instances of node running or shut down and restart, that might kill any process running. Try again, the issue should be solved.

pkill node solved my problem

This worked for me

Check which process is listening on that port using:
fuser <port_no>/tcp
then kill that process using
kill -9 pid