[SOLVED] Unable to connect to the database. Retrying


I’m trying to connect to the database, seems like the set-up is correct, but for some reason, it says that it is not available.


import { Module } from "@nestjs/common"
import { MongooseModule } from "@nestjs/mongoose";
import { ConfigModule } from "../config";
import { CreatorModule } from "./creator.module";

    imports: [
        MongooseModule.forRoot('mongodb://localhost:27017/snaptoon', {
            useCreateIndex: true,
            useUnifiedTopology: true,
            useNewUrlParser: true,
    controllers: [],
    providers: []

export class AppModule {}

The error is: ERROR [MongooseModule] Unable to connect to the database. Retrying (9)...

I’m using '@nestjs/mongoose': '9.0.2'


I solved by updating manually mongoose version to 6.2.2

 WARN @nestjs/[email protected] requires a peer of mongoose@^6.0.2 but none is installed. You must install peer dependencies yourself.

I realize due to this error on npm install

just use:

 npm install [email protected] --save

Answered By – Carlos E Torres Fernández

Answer Checked By – Mildred Charles (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *