title: Running Meteor on localhost fails with RangeError: port should be >= 0 and < 65536: NaN
body: <p>I am running a project on localhost using node and Mongodb, but it fails with an error as soon as I try to create a collection on the database.</p>
  
  <p>I am building the project with this script:</p>
  
  <pre><code>cd ~/Meteor/daily-reminder
  meteor build ~/build-output-daily-reminder --server=http://localhost
  cd ~/build-output-daily-reminder
  tar -xvzf daily-reminder.tar.gz
  rm daily-reminder.tar.gz
  cd ~/build-output-daily-reminder/bundle
  (cd programs/server &amp;&amp; npm install)
  export MONGO_URL='mongodb://username:password@http://localhost:27017/daily-reminder'
  export ROOT_URL='http://localhost/'
  export PORT='3000'
  echo "now run node main.js"
  node main.js
  </code></pre>
  
  <p>(I use my actual mongodb username and password in the real code).</p>
  
  <p>The project builds fine, but node won't run. It generates this error:</p>
  
  <pre><code>now run node main.js
  /home/shelagh/build-output-daily-reminder/bundle/programs/server/node_modules/fibers/future.js:245
                          throw(ex);
                                ^
  RangeError: port should be &gt;= 0 and &lt; 65536: NaN
      at Socket.connect (net.js:917:13)
      at Object.exports.connect.exports.createConnection (net.js:92:35)
      at [object Object].Connection.start (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:173:29)
      at _connect (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:211:16)
      at [object Object].ConnectionPool.start (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:231:3)
      at Server.connect (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/server.js:708:18)
      at Db.open (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:281:23)
      at connectFunction (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/mongo_client.js:275:67)
      at Function.MongoClient.connect (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/mongo_client.js:345:5)
      at Function.Db.connect (/home/shelagh/build-output-daily-reminder/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/db.js:2094:23)
  </code></pre>
  
  <p>If I use a newly-created Meteor project then node runs ok. But it fails as soon as I add this line to start of my js file:</p>
  
  <pre><code>Tasks = new Mongo.Collection("tasks");
  </code></pre>
  
  <p>It seems like there is some problem as soon as the server tries to communicate with the database. But I can't see anything wrong with my MONGO_URL: port is specified as 27017. From the error, it looks like the port isn't even being passed in.</p>
  
  <p>I am using node v0.12.7 and MongoDB shell version: 2.4.9. I have started mongo by typing 'mongo' in a separate terminal window.</p>