title: Handling database environment configuration in Sails.js
body: <p>The issue I have is related to the following quote from the <a href="http://sailsjs.org/#/documentation/reference/sails.config/sails.config.connections.html#multiple-connections-for-an-adapter" rel="noreferrer">official documentation</a>:</p>
  
  <blockquote>
    <p>Note If any connection to an adapter is used by a model, then all connections to that adapter will be loaded on sails.lift, whether or not models are actually using them. In the example above, if a model was configured to use the localMysql connection, then both localMysql and remoteMysql would attempt to connect at run time. It is therefore good practice to split your connection configurations up by environment and save them to the appropriate environment-specific config files, or else comment out any connections that you don't want active.</p>
  </blockquote>
  
  <p>How can you configure the connection for a production server?</p>
  
  <p>My <strong>connections.js</strong> file looks like this:</p>
  
  <pre><code>module.exports.connections = {
  
    mongoDev: {
      adapter: 'sails-mongo',
      host: 'localhost',
      port: 27017,
      user: 'username',
      password: 'password',
      database: 'database'
    },
  
    mongoLive: {
      adapter: 'sails-mongo',
      host: 'host.mongolab.com',
      port: 31681,
      user: 'user',
      password: 'password',
      database: 'database'
    }   
  };
  </code></pre>
  
  <p>And in my environment config files I've got:</p>
  
  <p><strong>development.js</strong></p>
  
  <pre><code>module.exports = {
    models: {
      connection: 'mongoDev'
    }    
  };
  </code></pre>
  
  <p><strong>production.js</strong></p>
  
  <pre><code>module.exports = {
    models: {
       connection: 'mongoLive'
    },
    port: 3000,
  };
  </code></pre>
  
  <p>This works on my local machine, because the production database server is on an external server.
  On the production environment I'm getting the following error:</p>
  
  <pre><code>[Error: failed to connect to [localhost:27017]]
  </code></pre>
  
  <p>It works if I remove the mongoDev object from my the connections object.</p>
  
  <p>I've also tried using adaptors.js, but this only resulted in some deprecation errors.</p>
  
  <pre><code>$ sails -v
  info: v0.9.9
  </code></pre>
  
  <p>I'm getting something different when running <code>sails lift</code>:</p>
  
  <pre><code>info:    Sails         
  info:    v0.10.5
  </code></pre>