#Error connection mongodb

10 messages · Page 1 of 1 (latest)

cobalt badger
#

I have a simple app i implement mongodb from the official site documentation this is my code :

  imports: [
    MongooseModule.forRoot("mongodb://mongodb:27017/", {
      dbName: "mydb",
      auth: {
        username: "user",
        password: "user",
      },
    }),
    RegistrationModule,
    AuthModule,
  ],
  controllers: [AuthApiController],
  providers: [AuthApiService],
})
export class AuthApiModule {}

im trying this connection string also:
mongodb://user:user@localhost:27017/mydb

i got that error: MongoServerError: Authentication failed.

if set that connection string mongodb://mongodb:27017/mydb its connected well but when i send a request to the server it give me missing auth error

strong dagger
#

can you actually connect to mongo using Compass with that url? Also try without trailing slash

cobalt badger
strong dagger
#

.forRoot("mongodb://mongodb:27017/" => .forRoot("mongodb://mongodb:27017"

strong dagger
#

no docker or other network layer just a local install ?

#

also worth checking that it works as expected with mongo auth disabled

cobalt badger
strong dagger
#

I would search around there

cobalt badger