Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!