Michael Uy Michael Uy - 4 months ago 58
Node.js Question

Express JS with Node.JS

I am having a problem with my website. I am running Ubuntu 16.04.1 x64 with node.js. For my website, whenever I go to the other pages on my website. It directs them to the 404 page even though I have a routing set for it.

Here is my server.js file:

var http = require('http');
var express = require('express');
var fs = require('fs');
var bodyParser = require('body-parser');

var app = express();

app.use('/',express.static(__dirname + '/'));
app.use(bodyParser.urlencoded({ extended: false }));
app.engine('.html', require('ejs').__express);
app.set('view engine','html');

app.get('/', function(req, res){

app.get('/resume', function(req, res){

app.get('/contact', function(req, res){

app.use(function(req, res) {

app.listen(3000, function () {
console.log('Listening on port 3000!');

For my other configurations for nginx, everything has been based from this guide here: https://code.lengstorf.com/deploy-nodejs-ssl-digitalocean/


Found the solution for this. I have tried running this command: DEBUG=express:* node server.js and it returned with an error containing this

Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at Server._listen2 (net.js:1257:14)
at listen (net.js:1293:10)
at Server.listen (net.js:1389:5)
at EventEmitter.listen (/apps/michaeluy.me/node_modules/express/lib/application.js:617:24)
at Object.<anonymous> (/apps/michaeluy.me/server.js:30:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)

Now I simply changed 3000 to 5000 on my server.js file as seen here:

app.listen(5000, function () {
console.log('Listening on port 5000!');

and now. It works perfectly!