1

I'm trying to bundle and run Meteor (v1.0) as a raw Node project.

Here are the steps I've taken:

  1. $ cd app_dir
  2. $ meteor build build_dir.
  3. $ cd build_dir/programs/server
  4. $ npm install
  5. $ cd build_dir
  6. $ PORT=3000 MONGO_URL=mongodb://127.0.0.1:3001/meteor node main.js

At this point I get an error:

Exception in callback of async function: Error: failed to connect to [127.0.0.1:3001]
at null.<anonymous> (/Users/byrnef87/Sites/lookback-site/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/server.js:536:74)
at emit (events.js:106:17)
at null.<anonymous> (/Users/byrnef87/Sites/lookback-site/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at emit (events.js:98:17)
at Socket.<anonymous> (/Users/byrnef87/Sites/lookback-site/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:516:10)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)

Any ideas on what could be causing this or how to debug it?

Thanks!

francisbyrne
  • 187
  • 1
  • 8
  • try exporting the port and mongourl before starting the node process. use `export MONGO_URL="mongodb://myserver:27017/db_name"` and `export PORT=80`. Then start the node. `node main.js` – Rajanand02 Dec 03 '14 at 05:15
  • 1
    Once you bundle the app you should connect the app to mongodb installed in the computer, not to the meteor mongo. start the mongodb service and provide `27017` port which is a default port for mongo. refer [this](http://stackoverflow.com/a/14533175/2751392) and [this](http://stackoverflow.com/questions/17606340/how-to-deploy-a-meteor-application-to-my-own-server) – Rajanand02 Dec 03 '14 at 05:31
  • I tried both exporting the variables first and changing the port to 27017. Same error both times. – francisbyrne Dec 03 '14 at 14:27
  • then you are probably not running mongodb on 127.0.0.1. Are you sure you started it and it is running on the default port (27017)? – Christian Fritz Dec 03 '14 at 17:43
  • btw, when we say port, we mean the port for the mongodb, not the `PORT` variable, i.e., try `PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/meteor node main.js` – Christian Fritz Dec 03 '14 at 17:44

2 Answers2

1

The solution that ended up fixing it for me was just re-cloning the repo, upgrading node to the latest version, upgrading MongoDB to the latest version and running it with a ROOT_URL like so:

ROOT_URL=http://localhost:3000 PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/meteor node main.js
francisbyrne
  • 187
  • 1
  • 8
0

Once you've started mongodb you need to provide the port it is running on in the MONGO_URL:

PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/meteor node main.js

Christian Fritz
  • 20,641
  • 3
  • 42
  • 71