0

I'm trying to run payload CMS app and built the MongoDB image but when trying to connect to admin panel at http://localhost:3000/admin payload gives me that error.

[08:12:30] ERROR (payload): MongoServerError: command aggregate requires authentication
    at Connection.onMessage (D:\Projects\Channel-Backup\node_modules\mongodb\src\cmap\connection.ts:438:20)
    at MessageStream.<anonymous> (D:\Projects\Channel-Backup\node_modules\mongodb\src\cmap\connection.ts:256:56)
    at MessageStream.emit (node:events:513:28)
    at MessageStream.emit (node:domain:489:12)
    at processIncomingData (D:\Projects\Channel-Backup\node_modules\mongodb\src\cmap\message_stream.ts:193:14)
    at MessageStream._write (D:\Projects\Channel-Backup\node_modules\mongodb\src\cmap\message_stream.ts:70:5)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at MessageStream.Writable.write (node:internal/streams/writable:337:10)
    at Socket.ondata (node:internal/streams/readable:766:22)

and this is the container of MongoDB I'm using.

CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS         PORTS                      NAMES
9943b54be18b   mongo:6.0.6-jammy   "docker-entrypoint.s…"   30 minutes ago   Up 9 minutes   0.0.0.0:27017->27017/tcp  backup-database-1

I tried to check that I don't have more than one instance of mongo is running on my computer and found that only one instance is running but the error still exists

  • The error message is clear. You run your MongoDB with authentication (which is a good idea in any case) but you did not provide your credentials. – Wernfried Domscheit Jul 09 '23 at 07:59

1 Answers1

0

Modify MONGODB_URI to include the username and password.

For example,

MONGODB_URI=mongodb://username:password@127.0.0.1/payload-cms?authSource=admin
maxswjeon
  • 100
  • 1
  • 11