Error: listen EADDRINUSE

Asked By: Anonymous

I use the following example to setup an express server: .

I use gulp to kickstart several processes like minifying, vulcanizing and folding up my Polymer project.

The gulpfile.js is 364 lines big, but this is the part that matters:

// Build and serve the output from the dist build
appsPaths.forEach(function(app) {
  gulp.task('serve:dist:' + app,
    ['browser-sync', 'default:' + app]);

gulp.task('browser-sync', ['nodemon'], function () {

  // for more browser-sync config options:
    notify: false,
    snippetOptions: {
      rule: {
        match: '<span id="browser-sync-binding"></span>',
        fn: function (snippet) {
          return snippet;

    // informs browser-sync to proxy our expressjs app which would run at the following location
    proxy: 'http://localhost:3000',

    // informs browser-sync to use the following port for the proxied app
    // notice that the default port is 3000, which would clash with our expressjs
    port: 4000,

    // open the proxied app in chrome
    browser: ['google-chrome']

gulp.task('nodemon', function (cb) {
  var called = false;
  return $.nodemon({

    // nodemon our expressjs server
    script: 'server/app.js',

    // watch core server file(s) that require server restart on change
    watch: ['server/app.js']
    .on('start', function onStart() {
      // ensure start only got called once
      if (!called) { cb(); }
      called = true;
    .on('restart', function onRestart() {
      // reload connected browsers after a slight delay
      setTimeout(function reload() {
          stream: false

Now while this works great and all I still get the following error ending up in my gulp log:

^CDaniels-iMac:polymer dani$ gulp
[22:33:10] Using gulpfile ~/dev/company/polymer/gulpfile.js
[22:33:10] Starting 'nodemon'...
[22:33:10] Starting ''...
[22:33:10] Finished '' after 8.56 ms
[22:33:10] Starting ''...
[22:33:10] Starting ''...
[22:33:10] Starting ''...
[22:33:11] Finished '' after 295 ms
[22:33:11] [nodemon] 1.9.2
[22:33:11] [nodemon] to restart at any time, enter `rs`
[22:33:11] [nodemon] watching: server/app.js
[22:33:11] [nodemon] starting `node server/app.js`
[22:33:11] Finished 'nodemon' after 570 ms
[22:33:11] Starting 'browser-sync'...
[22:33:11] Finished 'browser-sync' after 20 ms
      throw er; // Unhandled 'error' event

Error: listen EADDRINUSE
    at Object.exports._errnoException (util.js:890:11)
    at exports._exceptionWithHostPort (util.js:913:20)
    at Server._listen2 (net.js:1234:14)
    at listen (net.js:1270:10)
    at net.js:1379:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:63:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:82:10)
[22:33:11] [nodemon] app crashed - waiting for file changes before starting...
[BS] Proxying: http://localhost:3000
[BS] Access URLs:
       Local: http://localhost:4000
          UI: http://localhost:3001
 UI External:
[22:33:12] copy all files 16.03 MB
[22:33:12] Finished '' after 1.78 s
[22:33:12] Starting ''...
[22:33:12] Finished '' after 5.39 ms
[22:33:12] Starting ''...
[22:33:12] Starting ''...
[22:33:12] Starting ''...
[22:33:12] Starting ''...
[22:33:12] Finished '' after 339 ms
[22:33:12] Finished '' after 157 ms
[BS] Reloading Browsers...

This is what I see before and after triggering a run of the gulp script:

Daniels-iMac:polymer dani$ lsof -i tcp:3000
Daniels-iMac:polymer dani$
Daniels-iMac:polymer dani$ lsof -i tcp:3000
node    95580 dani   19u  IPv4 0x8560662b0408bad3      0t0  TCP localhost:hbci (LISTEN)

So it appears there’s not a lot going on on port 3000. What can I do to resolve this error?


Answered By: Anonymous

I think you’re running browserSync with the same ports several times on http://localhost:3000 due to the forEach, which I assume has several paths.

techinplanet staff

techinplanet staff

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno