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

279
Views
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 answers
Answer question

0

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

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!