$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - NodeJS , gulp , Error: listen EADDRINUSE :::3000 - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - NodeJS , gulp , Error: listen EADDRINUSE :::3000 - Stack Overflow

matteradmin14PV0评论

i am working with NodeJS and i am using gulp.

My foler look like that :

Root 
  dist
  node_modules
  src
    index.html
  gulpfile.js
  package.json

My gulpfile is :

"use strict";

var gulp = require('gulp');
var connect = require('gulp-connect'); // runs a local dev server 
var open = require('gulp-open'); // open a URL in a web browser

var config ={
    port : 3000,
    devBaseUrl : 'http://localhost',
    paths:{
        html:'./src/*.html',
        dist:'./dist'
    }
}

//Start a local development server 
gulp.task = ('connect' , function(){
    connect.server({
        root:['dist'],
        port: config.port,
        base: config.devBaseUrl,
    }); 
});

gulp.task('open', ['connect'], function(){
    gulp.src('dist/index.html').pipe(open({uri: config.devBaseUrl + ":" + config.port + '/'}))
});

gulp.task('html',function(){
    gulp.src(config.paths.html)
        .pipe(gulp.dest(config.paths.dist))
        .pipe(connect.reload());
});

gulp.task('default', ['html', 'open']);

When i am type 'gulp' in the cmd i get this error :

C:\Users\maor\Documents\NodeProject\2>gulp
[13:18:28] Using gulpfile ~\Documents\NodeProject\2\gulpfile.js
[13:18:28] Server started http://localhost:3000
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at Server._listen2 (net.js:1262:14)
    at listen (net.js:1298:10)
    at Server.listen (net.js:1394:5)
    at ConnectApp.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:57:19)
    at new ConnectApp (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:37:10)
    at Object.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:170:12)
    at Gulp.gulp.task (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:18:10)
    at Object.<anonymous> (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:29:6)

I really dont know what the problem is , i already checked and the port : 3000 is free. can you guys help me figure what the problem is ?

i am working with NodeJS and i am using gulp.

My foler look like that :

Root 
  dist
  node_modules
  src
    index.html
  gulpfile.js
  package.json

My gulpfile is :

"use strict";

var gulp = require('gulp');
var connect = require('gulp-connect'); // runs a local dev server 
var open = require('gulp-open'); // open a URL in a web browser

var config ={
    port : 3000,
    devBaseUrl : 'http://localhost',
    paths:{
        html:'./src/*.html',
        dist:'./dist'
    }
}

//Start a local development server 
gulp.task = ('connect' , function(){
    connect.server({
        root:['dist'],
        port: config.port,
        base: config.devBaseUrl,
    }); 
});

gulp.task('open', ['connect'], function(){
    gulp.src('dist/index.html').pipe(open({uri: config.devBaseUrl + ":" + config.port + '/'}))
});

gulp.task('html',function(){
    gulp.src(config.paths.html)
        .pipe(gulp.dest(config.paths.dist))
        .pipe(connect.reload());
});

gulp.task('default', ['html', 'open']);

When i am type 'gulp' in the cmd i get this error :

C:\Users\maor\Documents\NodeProject\2>gulp
[13:18:28] Using gulpfile ~\Documents\NodeProject\2\gulpfile.js
[13:18:28] Server started http://localhost:3000
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at Server._listen2 (net.js:1262:14)
    at listen (net.js:1298:10)
    at Server.listen (net.js:1394:5)
    at ConnectApp.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:57:19)
    at new ConnectApp (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:37:10)
    at Object.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:170:12)
    at Gulp.gulp.task (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:18:10)
    at Object.<anonymous> (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:29:6)

I really dont know what the problem is , i already checked and the port : 3000 is free. can you guys help me figure what the problem is ?

Share Improve this question asked Mar 22, 2017 at 12:03 TalTal 2355 silver badges14 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

Are you running any other applications that might be using port 3000?

It's possible that a previous instance of node may still be running, even if you intended to kill it. Check your processes, I sometimes get this issue and generally use

killall node

to resolve it.

This problem arise, when node process already running on the port.

You can fix it by

pkill node

OR you can use this

killall node

you still see node process with this mand: ps aux | grep node.

If you are using windows, then open task manager & in process tab, search node & right click on that process & end process.

Surely it will work.

Or better still you can change the port number to something else like 8000.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far