error and server nodejs after 2 minutes

Asked

Viewed 150 times

0

Good evening guys I have a basic program that until yesterday was good, today afternoon started the error in the execution of the "app nodemon" or only the "app Node"

follows the error:

throw er // unhandled 'error' Event error: read ECONNRESET at _errnoExecmption (util.js:992:11 at TCP.onread (net.js:618:25)

Searching everyone say that it is because the port is in use by another process, but I do not believe, because the server goes up and after 2 minutes, OBS.. Two minutes without me messing with the system if I’m using the system, it won’t stop. I even timed it. With the nodemon it stands in a message in red saying he’s waiting for a correction. I already undone the last changes I added to the system, which was a call to a search screen via a post flumulario (was working well the search).

Does anyone know what it can be??

Below I leave my app.js (pretty basic)

var express = require('express');

var app = express();

var port = process.env.PORT || 3000;

var passport = require('passport');
var flash = require('connect-flash');
var path = require('path');

var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var expressLayouts = require('express-ejs-layouts')

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

require('./config/passport')(passport); // passo o  passport para configuração

//configurar nossa aplicação express

app.use(morgan('dev')); // registrar cada pedido para o console
app.use(cookieParser()); // ler cookies (necessários para autenticação)
//app.use(bodyParser()); // obter informações de formulários html

//ver configuração do motor
app.use(express.static(path.join(__dirname, 'public')));
app.set('views', path.join(__dirname, 'app/views'));
app.set('view engine', 'ejs');

app.use(expressLayouts);

app.use(session({
    secret: 'SessaoSecreta...',
    resave: true,
    saveUninitialized: true
}));

app.use(passport.initialize());
app.use(passport.session()); // sessões de login persistentes
app.use(flash()); // use o flash de conexão para mensagens flash armazenadas na sessão

require('./config/routes.js')(app, passport); // carregar nossas rotas e passar em nosso aplicativo e passaporte totalmente configurado

app.listen(port);

console.log('  ');
console.log('Conectado em ===>  ' + port);
console.log('  ');
console.log('  ');


//pegar 404 e encaminhar para manipulador de erro
app.use(function (req, res, next) {
    res.status(404).render('404', { title: "Desculpe, página nao encontrada", session: req.sessionbo });
});

app.use(function (req, res, next) {
    res.status(500).render('404', { title: "Desculpe, página nao encontrada" });
});

exports = module.exports = app;

Needing more information here guys, thank you!! at+

  • There are several apparent problems in your code, you are giving a Latvian port and exporting the app and module, the status 500 middleware are are also in an incorrect position, should be after the routes and before the Latvian. Why export the app? Don’t use both Xports. I created a repository so I don’t have to keep creating the structure from scratch Github

  • Oh yeah, I’m going!! , on the server stop, I discovered that it is mysql when accessing it hosting on some server on the web, qndo is localhost it safe, I will look at the obg repositorio!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.