Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

409
Views
Nest server not connecting to MongoDB cloud UnhandledPromiseRejectionWarning: MongoParseError: URI malformed

My NestJS backend needs to connect to the mongodb cloud, I followed the docs from here

The following error threw up in the terminal:

    (node:6920) UnhandledPromiseRejectionWarning: MongoParseError: URI malformed
    at new ConnectionString (D:\growth\quizbackend\quizbackend\node_modules\mongodb-connection-string-url\src\index.ts:113:13)
    at Object.parseOptions (D:\growth\quizbackend\quizbackend\node_modules\mongodb\src\connection_string.ts:249:15)
    at new MongoClient (D:\growth\quizbackend\quizbackend\node_modules\mongodb\src\mongo_client.ts:332:22)
    at D:\growth\quizbackend\quizbackend\node_modules\mongoose\lib\connection.js:785:16
    at new Promise (<anonymous>)
    at NativeConnection.Connection.openUri (D:\growth\quizbackend\quizbackend\node_modules\mongoose\lib\connection.js:782:19)
    at Mongoose.createConnection (D:\growth\quizbackend\quizbackend\node_modules\mongoose\lib\index.js:275:10)
    at Function.<anonymous> (D:\growth\quizbackend\quizbackend\node_modules\@nestjs\mongoose\dist\mongoose-core.module.js:60:63)
    at Generator.next (<anonymous>)
    at D:\growth\quizbackend\quizbackend\node_modules\@nestjs\mongoose\dist\mongoose-core.module.js:20:71
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6920) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:6920) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, 
promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My app module code:

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from './users/users.module';
import {MongooseModule} from '@nestjs/mongoose'
@Module({
  imports: [UsersModule,MongooseModule.forRoot('mongodb+srv://samiurkhan:%$321@cluster0.8rxa2.mongodb.net/nest-js-db?retryWrites=true&w=majority')],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

I doubled check my username and password but they are correct, is there any need for encoding them or why the error is throwing up any explanation would be appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Ensure that your username and password in the URI Connection string doesn't have any illegal characters.

If the username or password includes the following characters:

: / ? # [ ] @

those characters must be converted using percent encoding.

Based on their documentation: https://docs.mongodb.com/manual/reference/connection-string/

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!