julio izquierdo
julio izquierdo

Reputation: 75

Unable to connect to the database - Mongoose nestJS

Currently I Attempt to connect to a database mongodb. But I get it error:

[MongooseModule] Unable to connect to the database. Retrying (1)... +30015ms

I use connection through openshift, something like that:

oc port-forward mongors-0 27019:27017

In the code configuration in nestJs I have follow:

    @Module({
  imports: [MongooseModule.forRoot( serviceConfig.mongoUrl, { useNewUrlParser: true, useUnifiedTopology: false }),
    CommonModule, AccountingModule],
  controllers: [AppController],
})
export class AppModule { }

The problems is when I use this configuration option: useUnifiedTopology: true, when I use the value false the connection is correct.

The serviceConfig.mongoUrl value is:

mongodb://localhost:27019/PAGOS

If someone Can help me, I apreciate that.

Thanks Regards

Upvotes: 3

Views: 2731

Answers (1)

Runkun Miao
Runkun Miao

Reputation: 345

Try change localhost => 127.0.0.1

I had same problem, this works fine

Upvotes: 4

Related Questions