Reputation: 235
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 ?
Upvotes: 0
Views: 7979
Reputation: 971
Or better still you can change the port number to something else like 8000.
Upvotes: 4
Reputation: 1507
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 command: 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.
Upvotes: 4
Reputation: 71
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.
Upvotes: 7