ERROR: Error: cannot connect to MongoDB. Details: Authentication failed.
sarbazx
TRIALOP

2 years ago

Hi, cannot connect to mongodb service,

I have added DATABSE_URI environment variable with mongodb connection string.

What am I doing wrong?

can connect through compass and mongosh

https://railway.app/project/9212a09d-f16a-4372-b29d-8de4d6273724

9 Replies

2 years ago

Please provide any error messages you are getting.


sarbazx
TRIALOP

2 years ago

#13 95.46 [20:53:37] ERROR: Error: cannot connect to MongoDB. Details: Authentication failed.

#13 95.49 u [MongoServerError]: Authentication failed.

#13 95.49     at z.onMessage (/app/.next/server/chunks/1931.js:235:80489)

#13 95.49     at N.<anonymous> (/app/.next/server/chunks/1931.js:235:78122)

#13 95.49     at N.emit (node:events:520:28)

#13 95.49     at b (/app/.next/server/chunks/1931.js:235:101845)

#13 95.49     at N._write (/app/.next/server/chunks/1931.js:235:100528)

#13 95.49     at writeOrBuffer (node:internal/streams/writable:564:12)

#13 95.49     at _write (node:internal/streams/writable:493:10)

#13 95.49     at Writable.write (node:internal/streams/writable:502:10)

#13 95.49     at Socket.ondata (node:internal/streams/readable:1007:22)

#13 95.49     at Socket.emit (node:events:520:28) {

#13 95.49   ok: 0,

#13 95.49   code: 18,

#13 95.49   codeName: 'AuthenticationFailed',

#13 95.49   connectionGeneration: 0,

#13 95.49   [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }

#13 95.49 }

 

2 years ago

Seems like you are using the incorrect variables.


sarbazx
TRIALOP

2 years ago

I also have following error, how variables should be added?

 - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "NEXT_PRIVATE_DRAFT_SECRET") (line 11)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "NEXT_PRIVATE_REVALIDATION_KEY") (line 11)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "PAYLOAD_PUBLIC_DRAFT_SECRET") (line 11)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "PAYLOAD_SECRET") (line 11)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "REVALIDATION_KEY") (line 11)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "NEXT_PRIVATE_DRAFT_SECRET") (line 12)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "NEXT_PRIVATE_REVALIDATION_KEY") (line 12)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "PAYLOAD_PUBLIC_DRAFT_SECRET") (line 12)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "PAYLOAD_SECRET") (line 12)

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "REVALIDATION_KEY") (line 12)

UndefinedVar: Usage of undefined variable '$NIXPACKS_PATH' (line 18)

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 18)
 

Dockerfile:25

2 years ago

There is nothing to worry about there.


sarbazx
TRIALOP

2 years ago

I'm accessing the env variable like this:

db: mongooseAdapter({
    url: process.env.DATABASE_URI,
  })

then set this env variable on services variables tab. is this correct way to access railway service env variable?


2 years ago

You would need to reference the mongoose docs for that.


sarbazx
TRIALOP

2 years ago

also cannot connect through data tab from mongo db service.

but can connect through mongosh from terminal.

Attachments


2 years ago

The data tab has since been fixed, please let me know if you continue to experience issues with it.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...