ingrese la descripción de la imagen aquí
No puedo conectar mi base de datos y tengo este problema cuando ejecuto cualquier llamada API en Postman, he intentado muchas cosas pero no puedo solucionarlo.
Esto es probablemente porque
Iniciar MongoDB:
sudo systemctl start mongodVerifique que MongoDB se haya iniciado correctamente:
sudo systemctl status mongod
Buscar pid:
lsof -i:27017Matar pid:
kill -9 pid
mongoose.connect('mongodb://localhost:27017/myapp');
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); }) })