Not sure why it's returning this auth error when I've just setup a Mongo account and double checked the details. I've added 0.0.0.0 for the ip includes too.
This is a fresh Payload project.
Any ideas?
Packages are up to date when I run 'yarn'
MONGODB_URI=mongodb+srv://taunhealy:<password>@cluster0.r1zqvrw.mongodb.net/
PAYLOAD_SECRET=4514798b4de5bf6843ac4f
I've replaced password with the correct password and I have no special characters in the password.
server.ts
import express from 'express';
import payload from 'payload';
require('dotenv').config();
const app = express();
// Redirect root to Admin panel
app.get('/', (_, res) => {
res.redirect('/admin');
});
const start = async () => {
// Initialize Payload
await payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
})
// Add your own express routes here
app.listen(3000);
}
start();
Maybe try this after .net/
?retryWrites=true&w=majority
Thank, unfort it didn't work.
I changed my password to have no numbers and it still returned bad auth
Are you running payload locally or on a server?
locally
Mongo server is online
Have you added your IP address as well to the allowed IP addresses to access the db
In network access
Yea
Does anyone know of alternative connection methods to mongodb?
I've started a new Payload project and I'm receiving a different Mongodb error:
PS F:\git\TaunDevs\payload> yarn dev
yarn run v1.22.19
$ cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon
[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts
[nodemon] starting `ts-node src/server.ts`
[11:53:30] ERROR (payload): Error: cannot connect to MongoDB. Details: querySrv ENODATA _mongodb._tcp.taundevs.lm9ftk.mongodb.net
[nodemon] app crashed - waiting for file changes before starting...
I'm trying to connect to a different Mongo database that was working with Payload in the past and it's also returning an error:
[12:03:00] ERROR (payload): Error: cannot connect to MongoDB. Details: querySrv ENODATA _mongodb._tcp.cluster0.zpesqyk.mongodb.net
Solved temporarily by running locally and configuring the IP :
Star
Discord
online
Get dedicated engineering support directly from the Payload team.