backend-ico-dashboard
backend-ico-dashboard copied to clipboard
MongoError: getaddrinfo ENOTFOUND mongo mongo:27017
Hi,
I'm trying run project during to README
/usr/src/app # npm run start
> [email protected] start /usr/src/app
> nodemon -w ./src -e ts ./src/bin/www --exec ts-node
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /usr/src/app/src/**/*
[nodemon] starting `ts-node ./src/bin/www`
TypeORM connection error: { MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017]
at Pool.<anonymous> (/usr/src/app/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> (/usr/src/app/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> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:187:49)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
name: 'MongoError',
message: 'failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017]' }
JWT was generated successfully, .env was copied from .env.test
Hello! Could you please provide an output of docker-compose ps command?
@alexeymarunin
- Exit current container (just type
exit) docker-compose downdocker-compose up -d- Wait couple of seconds and then
docker-compose ps
@hlogeon,
> docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------
backendicodashboard_auth_1 /bin/sh -c npm start Up 0.0.0.0:32799->3000/tcp, 0.0.0.0:32798->4000/tcp
backendicodashboard_ico_1 /bin/sh Up 0.0.0.0:3000->3000/tcp,0.0.0.0:80->3000/tcp, 0.0.0.0:443->4000/tcp
backendicodashboard_mongo_1 /root/run.sh mongod Exit 100
backendicodashboard_redis_1 docker-entrypoint.sh redis ... Up 0.0.0.0:32796->6379/tcp
backendicodashboard_rpc_1 /bin/sh -c /parity/parity ... Up 8080/tcp, 8180/tcp, 8545/tcp, 0.0.0.0:32797->8546/tcp
backendicodashboard_verify_1 /bin/sh -c npm run serve Up
@alexeymarunin
so it looks like your mongodb container did not started. Could you attach output of docker-compose logs mongo as well?
@hlogeon
> docker-compose logs mongo
Attaching to backendicodashboard_mongo_1
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=e9aa111a59ca
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] db version v3.4.9
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] OpenSSL version: LibreSSL 2.5.5
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] allocator: system
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] modules: none
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] build environment:
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] distarch: x86_64
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] target_arch: x86_64
mongo_1 | 2018-02-21T16:41:49.507+0000 I CONTROL [initandlisten] options: {}
mongo_1 | 2018-02-21T16:41:49.512+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=478M,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),
mongo_1 | 2018-02-21T16:41:49.550+0000 E STORAGE [initandlisten] WiredTiger error (17) [1519231309:550639][1:0x7ff606ba9b20], connection: /data/db/WiredTiger.wt: handle-open: open: File exists
mongo_1 | 2018-02-21T16:41:49.552+0000 I STORAGE [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.5
mongo_1 | 2018-02-21T16:41:49.553+0000 E STORAGE [initandlisten] WiredTiger error (1) [1519231309:553753][1:0x7ff606ba9b20], connection: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
mongo_1 | 2018-02-21T16:41:49.562+0000 I - [initandlisten] Assertion: 28595:1: Operation not permitted src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 269
mongo_1 | 2018-02-21T16:41:49.616+0000 I STORAGE [initandlisten] exception in initAndListen: 28595 1: Operation not permitted, terminating
mongo_1 | 2018-02-21T16:41:49.616+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
mongo_1 | 2018-02-21T16:41:49.616+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
mongo_1 | 2018-02-21T16:41:49.616+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
mongo_1 | 2018-02-21T16:41:49.616+0000 I CONTROL [initandlisten] now exiting
mongo_1 | 2018-02-21T16:41:49.616+0000 I CONTROL [initandlisten] shutting down with code:100
BTW, Windows 10 x64 Pro, build 1709 docker-compose version 1.17.1, build 6d101fb0 docker-py version: 2.5.1 CPython version: 2.7.14 OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
@alexeymarunin
Is there anything in your storage/mongodb folder? If yes try to clear this directory, docker-compose down and then start again. I haven't seen this error before and will try to figure out what's going on but may be my advice will solve the problem so write me please if you have any success.
If it works you get something like this as a result of docker-compose ps command:
> docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------
backendicodashboard_auth_1 /bin/sh -c npm start Up 0.0.0.0:32799->3000/tcp, 0.0.0.0:32798->4000/tcp
backendicodashboard_ico_1 /bin/sh Up 0.0.0.0:3000->3000/tcp,0.0.0.0:80->3000/tcp, 0.0.0.0:443->4000/tcp
backendicodashboard_mongo_1 /root/run.sh mongod Up
backendicodashboard_redis_1 docker-entrypoint.sh redis ... Up 0.0.0.0:32796->6379/tcp
backendicodashboard_rpc_1 /bin/sh -c /parity/parity ... Up 8080/tcp, 8180/tcp, 8545/tcp, 0.0.0.0:32797->8546/tcp
backendicodashboard_verify_1 /bin/sh -c npm run serve Up
Note the Up state of backendicodashboard_mongo_1 container
Folder storage/mongodb:
.gitignore
journal
mongod.lock
WiredTiger
WiredTiger.lock
WiredTiger.wt
I removed all files (except .gitignore) and re-run docker - the same result
> docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------
backendicodashboard_auth_1 /bin/sh -c npm start Up 0.0.0.0:32803->3000/tcp, 0.0.0.0:32802->4000/tcp
backendicodashboard_ico_1 /bin/sh Up 0.0.0.0:3000->3000/tcp,0.0.0.0:80->3000/tcp, 0.0.0.0:443->4000/tcp
backendicodashboard_mongo_1 /root/run.sh mongod Exit 100
backendicodashboard_redis_1 docker-entrypoint.sh redis ... Up 0.0.0.0:32801->6379/tcp
backendicodashboard_rpc_1 /bin/sh -c /parity/parity ... Up 8080/tcp, 8180/tcp, 8545/tcp, 0.0.0.0:32800->8546/tcp
backendicodashboard_verify_1 /bin/sh -c npm run serve Up
@alexeymarunin Hey, sorry for a long reply. Nobody in our team uses Windows so we cannot help really fast as we need to set up Virtual Machine with Windows to figure this out.
Your issue is connected with dockerized MongoDB which is using volumes. I think it would be faster if you try to google it by yourself. I found a couple of issues which looks pretty same Fir example: https://github.com/docker/for-win/issues/138
I can suggest you disable using volumes for mongoDB. In this case you will loose your data on mongo container restart. To do so you need to delete lines 80 and 81 from docker-compose.yml file.
https://github.com/JincorTech/backend-ico-dashboard/blob/develop/docker-compose.yml#L80
Seems I fixed this bug
@alexeymarunin Could you please tell me how did you fix your bug????
I have the same problem, my app service can connected to the volumed local mongodb, but no data retrieved. The error shows:
" Server running on localhost:3000
Warning { MongoError: failed to connect to server [db:27017] on first connect [MongoError: getaddrinfo ENOTFOUND db db:27017]
at Pool.
@maiziheimei Here is how he fixed it: https://github.com/alexeymarunin/backend-ico-dashboard/commit/ca8fb584476ce08a0383f4421fa5f88779bbbafb
I was with the same problem and I solved added useUnifiedTopology: true, in const options = { useNewUrlParser: true, useUnifiedTopology: true, }; I hope this helps someone!