I am new to node.js and was trying to build a login system using some help from the internet. But I am completely stumped by why I am getting ERR_NO_RESPONSE after I try to give a POST request . I am posting the codes. Any help would be appreciated.

The signup route is working well and the data gets saved into the mlab database that I have set up. But the login route doesn't respond when I am trying to do the post response.

router.js

var express = require('express'); var router = express.Router(); var User = require('../models/user'); var passport = require('passport'); var LocalStrategy = require('passport-local').Strategy; var utilities = require('../models/utilities'); // GET route for reading data router.get('/', function (req, res, next) { res.render('index'); }); router.get('/profile', function (req, res) { return res.render('profile'); }); router.route('/login') .get(function (req, res) { return res.render('login'); }) .post(function(req, res, next) { passport.authenticate('login',{ successRedirect : '/profile', // redirect to the secure profile section failureRedirect : '/', // redirect back to the signup page if there is an error failureFlash : true } )});

passport.js

var LocalStrategy = require('passport-local').Strategy; var passport = require('passport'); var User = require('../models/user'); module.exports = function(passport){ passport.serializeUser(function(user, done) { done(null, user.id); }); passport.deserializeUser(function(id, done) { User.findById(id, function(err, user) { if(err) { console.error('There was an error accessing the records of' + ' user with id: ' + id); return console.log(err.message); } return done(null, user); }) }); passport.use('login', new LocalStrategy({ usernameField : 'logemail', passwordField : 'logpassword', passReqToCallback : true }, function(req, email, password, done) { User.findOne({email: email}, function(err, user) { if(err) { return errHandler(err); } if(!user) { return done(null, false, {errMsg: 'User does not exist, please' + ' <a class="errMsg" href="/signup">signup</a>'}); } if(!user.validPassword(password)) { return done(null, false, {errMsg: 'Invalid password try again'}); } return done(null, user); }); }));

app.js