AlexGarrixen / vimox-api

MIT License
11 stars 10 forks source link

Ports not accepted with 'mongodb+srv' URIs #64

Open orophix opened 2 years ago

orophix commented 2 years ago

Sorry this is the first time I try out mongodb. What am I doing incorrectly?

Error conenction db: MongoParseError: Ports not accepted with 'mongodb+srv' URIs
    at parseSrvConnectionString (/home/vimox-api/node_modules/mongodb/lib/core/uri_parser.js:62:21)
    at parseConnectionString (/home/vimox-api/node_modules/mongodb/lib/core/uri_parser.js:611:12)
    at connect (/home/vimox-api/node_modules/mongodb/lib/operations/connect.js:283:3)
    at /home/vimox-api/node_modules/mongodb/lib/mongo_client.js:284:5
    at maybePromise (/home/vimox-api/node_modules/mongodb/lib/utils.js:692:3)
    at MongoClient.connect (/home/vimox-api/node_modules/mongodb/lib/mongo_client.js:280:10)
    at /home/vimox-api/node_modules/mongoose/lib/connection.js:836:12
    at new Promise (<anonymous>)
    at NativeConnection.Connection.openUri (/home/vimox-api/node_modules/mongoose/lib/connection.js:832:19)
    at /home/vimox-api/node_modules/mongoose/lib/index.js:351:10
    at /home/vimox-api/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/vimox-api/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/vimox-api/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/vimox-api/node_modules/mongoose/lib/index.js:350:20)
    at /home/vimox-api/src/db/connection.ts:11:20
AlexGarrixen commented 2 years ago

Have you set the environment variables?

It is worth mentioning that the mongodb atlas is used

The uri connection that mongo will provide you looks like this: mongodb+srv://{username}:{password}@${host}/${database}?retryWrites=true&w=majority

You must specify the username, password, host and database in an .env or .env.development or .env.production file