Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
Database connection problem and api calls

enter image description here

I am not able to connect my database and getting this problem when i run any api call in postman ,I have tried so many things but not able to get it out .

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This is probably because

  1. The MongoDB service isn't started.

Start MongoDB: sudo systemctl start mongod

Verify that MongoDB has started successfully: sudo systemctl status mongod

  1. The port is already serving some service.

Find pid: lsof -i:27017

Kill pid: kill -9 pid

  1. Your connection string is incorrect

mongoose.connect('mongodb://localhost:27017/myapp');

  1. Your localhost is not configured to use mongoDB
about 4 years ago · Juan Pablo Isaza Denunciar

0

const app=require("./app");
const dotenv=require("dotenv");
const connectDatabase=require("./config/database");
PORT=4000;

//Handling uncaught Exception(YouTube Wala Error)
process.on("uncaughtException",(err)=>{
    console.log(`Error:${err.message}`);
    console.log(`Shuting Down the server due to uncaught Exception`);
    process.exit(1);
})




// config
// dotenv.config({path:"backend/config/config.env"});


//Connecting to database
connectDatabase();

const server=app.listen(PORT,()=>{
    console.log(`server is running on http://localhost:${PORT}`);
})

   



//Unhandled Promise Rejection-> in case when we use mongo(using)
process.on("unhandledRejection",err=>{
    console.log(`Error: ${err.message}`);
    console.log(`Shuting Down the server due to Unhandled Promise Rejection`);

    server.close(() =>{ 
   process.exit(1);
    })
})

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda