Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

422
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda