Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
invalid schema, expected mongodb for process.env variable

I'm trying to set up mongodb for heroku and I can successfully connect if i put the url in the script normally. However, when I retrieve the url from environmental variables locally to hide it, I get the error 'invalid schema, expected mongodb'.

It's returning the exact same url in the format var url = 'mongodb://username:password@ds139619.mlab.com:39619/food'

Process.env isn't asynchronous is it? I can print the url correctly before the connect fails. I also checked the type and it is a string too.

//var url = 'mongodb://<username>:<password>@ds139619.mlab.com:39619/food';
var url = process.env.MONGOLAB_URI;
var ok = process.env.MONGOLAB_URI;

console.log(ok);


// Use connect method to connect to the Server
MongoClient.connect(url, function (err, db) {
if (err) {
    console.log('Unable to connect to the mongoDB server. Error:', err);
} else {
    console.log('Connection established to', url);

    // do some work here with the database.

    //Close connection
    db.close();
}
});
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I solved the problem by removing the quotations marks I used when saving the environment variables

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda