abernix/meteord

ECONNREFUSED error

Closed this issue · 1 comments

I'm getting an ECONNREFUSED error in my meteor app so I tried going back to a built in example

$ git clone https://github.com/meteor/todos tst
$ cd tst
$ meteor npm install
$ meteor update
$ meteor update --all-packages
$ meteor npm install --save bcrypt
$ meteor

This works, so far so good. Okay, make a docker-compose.yml that uses this repo and a 3.2 version of mongodb (matches what meteor mongo claims is the version used by 1.6).

meteor:
  container_name: tst_meteor_1
  image: abernix/meteord:node-8-devbuild
  ports:
   - "3000:80"
  links:
   - mongo
  volumes:
   - ../output:/bundle
  environment:
   - ROOT_URL=http://localhost:3000
   - METEOR_ALLOW_SUPERUSER=true
   - MONGO_URL=mongodb://localhost:27017/meteor

mongo:
  container_name: tst_mongo_1
  image: mongo:3.2-jessie
  ports:
   - "127.0.0.1:27017:27017"

Now build the app and run it in docker

$ meteor build  ../output --architecture=os.linux.x86_64 --server-only
$ docker-compose --file docker-compose.yml up -d

Check that mongo is runnning

$ docker logs -f tst_mongo_1
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=012d211f6526
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] db version v3.2.17
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] git version: 186656d79574f7dfe0831a7e7821292ab380f667
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1t  3 May 2016
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] modules: none
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] build environment:
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten]     distmod: debian81
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten]     distarch: x86_64
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2017-11-26T04:48:28.340+0000 I CONTROL  [initandlisten] options: {}
2017-11-26T04:48:28.343+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-11-26T04:48:28.380+0000 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2017-11-26T04:48:28.380+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2017-11-26T04:48:28.381+0000 I NETWORK  [initandlisten] waiting for connections on port 27017

Yes, check that meteor is running

$ docker logs -f tst_meteor_1

> meteor-dev-bundle@0.0.0 install /bundle/bundle/programs/server
> node npm-rebuild.js


> bcrypt@1.0.3 install /bundle/bundle/programs/server/npm/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

[bcrypt] Success: "/bundle/bundle/programs/server/npm/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote

> fibers@2.0.0 install /bundle/bundle/programs/server/npm/node_modules/fibers
> node build.js || nodejs build.js

`linux-x64-57` exists; testing
Binary is fine; exiting
abbrev@1.1.1 /bundle/bundle/programs/server/npm/node_modules/abbrev
... 202 lines of node_modules
indexof@0.0.1 /bundle/bundle/programs/server/npm/node_modules/meteor-node-stubs/node_modules/indexof
{
  "meteor-dev-bundle": "0.0.0",
  "npm": "5.5.1",
  "ares": "1.10.1-DEV",
  "cldr": "31.0.1",
  "http_parser": "2.7.0",
  "icu": "59.1",
  "modules": "57",
  "nghttp2": "1.25.0",
  "node": "8.9.1",
  "openssl": "1.0.2m",
  "tz": "2017b",
  "unicode": "9.0",
  "uv": "1.15.0",
  "v8": "6.1.534.47",
  "zlib": "1.2.11"
}
npm WARN meteor-dev-bundle@0.0.0 No description
npm WARN meteor-dev-bundle@0.0.0 No repository field.
npm WARN meteor-dev-bundle@0.0.0 No license field.

up to date in 9.48s
=> Starting meteor app on port:80

/bundle/bundle/programs/server/node_modules/fibers/future.js:313
						throw(ex);
						^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
    at Pool.<anonymous> (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:336:35)
    at emitOne (events.js:116:13)
    at Pool.emit (events.js:211:7)
    at Connection.<anonymous> (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:280:12)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at Connection.emit (events.js:214:7)
    at Socket.<anonymous> (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:187:49)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)

And I get the ECONNREFUSED error

I'm only guessing this is a docker configuration issue. I was running docker-machine in the past but recently upgrading to docker mac and have been working through things that needed to change in my setup. That led to trying something more "official"

Any idea how to fix this issue?

Some other things I tried,

  • moving ports
  • not mapping the internal docker port to the same host port
  • not using a database name (my old configuration didn't need one)

Apparently the issue is docker now needs the container name for the mongo url

was:

environment:
 - MONGO_URL=mongodb://localhost:27017/meteor

now:

environment:
 - MONGO_URL=mongodb://mongo:27017/meteor

where mongo is the name of the service

 - MONGO_URL=mongodb://<name-of-service>:27017/meteor