Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8731977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:21:19+00:00 2026-06-13T09:21:19+00:00

I have a mongodb replica set on mongolab. I’m using nodejs + mongoose. When

  • 0

I have a mongodb replica set on mongolab.

I’m using nodejs + mongoose. When I’m trying to connect from my local machine everything goes ok.
But after deployment to heroku something wrong happens and mongoose got strange error:

[Error: no primary server found in set]

Here some code (server.js):

async.series([
  function(callback){
    console.log('DB Connection: ' + siteConf.mongo_url);
    mongoose.connect(siteConf.mongo_url, siteConf.mongo_options, callback);
  },      
  function(callback){
    http.createServer(app).listen(siteConf.port, callback);
  }
],
function(err, results){

 if (err) {
   console.log(err);
 }

 console.log('Running in ' + (process.env.NODE_ENV || 'development') + ' mode @ ' + siteConf.uri);
  }
);

This url I’m using as connection string:

mongodb://username:password@someid-a0.mongolab.com:39897/pm_prod,mongodb://someid-a1.mongolab.com:39897

The main thing I can’t understand is: what is the differences between my maching and heroku cloud hosting.

I already tried to remove node_modules and npm install them to be sure that I have same versions as on heroku. (Because heroku do this on each deploy).

Thanks, and sorry for my bad english

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:21:20+00:00Added an answer on June 13, 2026 at 9:21 am

    This may be a URI problem. The format for DB URIs is:

    mongodb://<user>:<pass>@host:port,host:port,...,host:port/db_name
    

    That means that

    mongodb://username:password@someid-a0.mongolab.com:39897/pm_prod,mongodb://someid-a1.mongolab.com:39897
    

    should be:

    mongodb://username:password@someid-a0.mongolab.com:39897,someid-a1.mongolab.com:39897/pm_prod
    

    It’s also worth noting for others: If you are using Heroku’s MongoLab add-on, your URI is available as an environment variable at process.env.MONGOLAB_URI, so you don’t have to place the URI in your code.

    This could also be related to a running question about connectivity between Heroku and Mongo. See https://github.com/jcottr/temps-mort, which references two tickets for the Node Mongo driver:

    https://jira.mongodb.org/browse/NODE-4

    https://jira.mongodb.org/browse/NODE-5

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am simulating MongoDB replica set step-downs and trying to have my application and
I'm using Doctrine ODM to connect to MongoDB. I have a three node replica
I have a mongodb replicaset on ubuntu.. In replica set, hosts are defined as
I have a MongoDB 2.2 replicaset setup (2 nodes), and connect to test using
here's my problem: I have a MongoDB Replica Set which I will have to
I have nodejs application with mongodb(mongoose). like this: var mongoose = require('mongoose'); var express
I'm running a MongoDB instance using a Replica Set, when there are a lot
I'm currently working on a 'simple' photo sytem with mongoDB, using a Replica Set
I have mongodb running and using morphia. Having a Collection of BatchData Documents and
I have mongodb and NodeJs. The connection is done via mongoosejs . What is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.