Search code examples
mongodbmeanjs

Where do I put the database URL/IP


Not really sure where to put it. Tried alot of things and googled none worked.

module.exports = {
  db: {
    uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean-dev',
    options: {
      user: '',
      pass: ''
    },
    // Enable mongoose debug mode
    debug: process.env.MONGODB_DEBUG || false
  },

Solution

  • You can add the URL/IP in two ways:

    • Using the process env: MONGOHQ_URL=localhost node server.js
    • By replacing the uri:

      uri: 'mongodb://user:password@localhost/mean-dev/'

      OR

      uri: 'mongodb://localhost/mean-dev/'

    If you have IP, replace the localhost with it.