Home > database >  Unable to connect to the database. Retrying
Unable to connect to the database. Retrying

Time:01-19

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.

app.module.ts

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

@Module({
    imports: [
        MongooseModule.forRoot('mongodb://localhost:27017/snaptoon', {
            useCreateIndex: true,
            useUnifiedTopology: true,
            useNewUrlParser: true,
        }),
        CreatorModule,
    ],
    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'

CodePudding user response:

Please check if your MongoDB is running. Try instead also connect via the MongoDB Compass. Ensure everything is working. You might wanna also check if there is an username and password required for authentication. Your code looks good to me.

  •  Tags:  
  • Related