无法连接到数据库-Mongoose nestJS



当前我尝试连接到数据库mongodb。但我弄错了:

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

我通过openshift使用连接,类似于

oc port-forward mongors-0 27019:27017

在nestJs中的代码配置中,我有以下内容:

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

问题是当我使用这个配置选项时:useUnifiedTopology:true,当我使用值false时,连接是正确的。

serviceConfig.mongoUrl值为:

mongodb://localhost:27019/PAGOS

如果有人能帮我,我很感激。

谢谢问候

尝试更改localhost=>127.0.0.1

我也有同样的问题,这很好

最新更新