Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGeorge Akinian
17,615 PointsHi, it's throwing an error: listen EADDRINUSE :::3000 Unhandled "error" event.
I think it may have to do with other processes using the same port, I tried killall but it didn't resolve.
Here's the error msg and my code.
'use strict';
var express = require('express'),
posts = require('./mock/posts.json');
var app = express();
app.set('view engine', 'jade');
app.set('views', __dirname + '/templates')
app.get('/', function(req, res){
res.render('index')
});
app.get('/blog/:title?', function(req, res){
var title = req.params.title;
if (title === undefined) {
res.status(503);
res.send("This page is under construction!");
} else {
var post = posts[title] || {};
res.render('post', { post: post});
}
});
app.listen(3000, function() {
console.log("The frontend server is running on port 3000!");
});
4 Answers
Nathan Williams
Python Web Development Techdegree Student 6,851 PointsIf you use lsof
, you can see what process is bound to the port with lsof -i:3000
, and then force kill it by grabbing the process id (aka pid
) and kill it with a kill -9 $pid
.
George Akinian
17,615 PointsGot it to work after complete system restart.
George Akinian
17,615 Pointsgot it, thanks.
George Akinian
17,615 PointsGeorge Akinian
17,615 Pointslsof unfolded a hyperwebster, lsof -i:3000 is not showing anything at all, while i have the server running on that port, and It should be showing that process bound to that port.
Nathan Williams
Python Web Development Techdegree Student 6,851 PointsNathan Williams
Python Web Development Techdegree Student 6,851 Pointsyou'll only see it if you have permissions; if you're running lsof as a different user than the app, try prefixing
lsof -i:$port
with sudo to make sure you have adequate permissions.John Knotts
Full Stack JavaScript Techdegree Student 10,836 PointsJohn Knotts
Full Stack JavaScript Techdegree Student 10,836 Pointsthanks Nathan!