0
我有一個應用程序在docker容器中運行,並且有docker compose。在日誌中,容器啓動數據庫並讓它偵聽端口27017Mongo連接拒絕ECCONREFUSED
在應用程序的後面,構建了該站點的其餘部分後,它將嘗試連接到該端口上的該數據庫,並失敗並顯示ECONNREFUSED 127.0.0.1: 27017
我想這可能是我不理解這裏很基本的東西,但幫助將不勝感激
Starting maroon_db_1
Recreating maroon_web_1
Attaching to maroon_db_1, maroon_web_1
db_1 | 2016-08-22T10:50:27.114+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=e3a671f93ded
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] db version v3.2.9
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] allocator: tcmalloc
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] modules: none
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] build environment:
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] distmod: debian71
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] distarch: x86_64
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] target_arch: x86_64
db_1 | 2016-08-22T10:50:27.115+0000 I CONTROL [initandlisten] options: {}
db_1 | 2016-08-22T10:50:27.150+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
db_1 | 2016-08-22T10:50:27.150+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(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),
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten]
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten]
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
db_1 | 2016-08-22T10:50:27.508+0000 I CONTROL [initandlisten]
db_1 | 2016-08-22T10:50:27.522+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
db_1 | 2016-08-22T10:50:27.522+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
db_1 | 2016-08-22T10:50:27.543+0000 I NETWORK [initandlisten] waiting for connections on port 27017
web_1 |
web_1 | > [email protected] bs /usr/src/app
web_1 | > npm run clean && npm run build && npm run build:server && npm run start:prod
web_1 |
web_1 |
web_1 | > [email protected] clean /usr/src/app
web_1 | > rimraf dist
web_1 |
web_1 |
web_1 | > [email protected] build /usr/src/app
web_1 | > cross-env NODE_ENV=production webpack --config webpack.config.prod.js
web_1 |
web_1 | This preset is no longer necessary and can be replaced by the following:
web_1 | presets: [
web_1 | ["es2015", { "modules": false }]
web_1 | ]
web_1 | Hash: afd840974c1321403cd5
web_1 | Version: webpack 2.1.0-beta.8
web_1 | Time: 19804ms
web_1 | Asset Size Chunks Chunk Names
web_1 | app.edcea8de66cc864a67a5.js 375 kB 3 [emitted] app
web_1 | bbaeb5f32b7042f0def39648a1d111b9.png 15.8 kB [emitted]
web_1 | vendor.js 148 kB 0 [emitted] vendor
web_1 | 1.b6dee935292b81563830.js 7.85 kB 1 [emitted]
web_1 | 2.6f2172bc1184d6c25200.js 1.55 kB 2 [emitted]
web_1 | chunk-manifest.json 97 bytes [emitted]
web_1 | app.edcea8de66cc864a67a5.css 3.04 kB 3 [emitted] app
web_1 | app.b6dee935292b81563830.css 708 bytes 1 [emitted]
web_1 | app.b6dee935292b81563830.css.map 105 bytes 1 [emitted]
web_1 | app.edcea8de66cc864a67a5.css.map 105 bytes 3 [emitted] app
web_1 | manifest.json 508 bytes [emitted]
web_1 | [648] multi app 28 bytes {3} [built]
web_1 | [649] multi vendor 40 bytes {0} [built]
web_1 | + 655 hidden modules
web_1 | Child extract-text-webpack-plugin:
web_1 | + 2 hidden modules
web_1 | Child extract-text-webpack-plugin:
web_1 | + 2 hidden modules
web_1 | Child extract-text-webpack-plugin:
web_1 | + 2 hidden modules
web_1 | Child extract-text-webpack-plugin:
web_1 | + 2 hidden modules
web_1 | Child extract-text-webpack-plugin:
web_1 | + 2 hidden modules
web_1 | Child extract-text-webpack-plugin:
web_1 | + 3 hidden modules
web_1 |
web_1 | > [email protected] build:server /usr/src/app
web_1 | > cross-env NODE_ENV=production webpack --config webpack.config.server.js
web_1 |
web_1 | This preset is no longer necessary and can be replaced by the following:
web_1 | presets: [
web_1 | ["es2015", { "modules": false }]
web_1 | ]
web_1 | babel-plugin-webpack-loader:
web_1 | To avoid caching errors you need to set BABEL_DISABLE_CACHE=1 environment variable.
web_1 | More information at issue #36
web_1 | Hash: eaa3e07d940766fdd179
web_1 | Version: webpack 2.1.0-beta.8
web_1 | Time: 74596ms
web_1 | Asset Size Chunks Chunk Names
web_1 | server.bundle.js 75.5 kB 0 [emitted] main
web_1 | + 63 hidden modules
web_1 |
web_1 | > [email protected] start:prod /usr/src/app
web_1 | > cross-env NODE_ENV=production node index.js
web_1 |
web_1 | was local
web_1 | server config { mongoURL: 'mongodb://localhost:27017/mern-starter',
web_1 | port: 3030 }
web_1 | MERN is running on port: 3030! Build something amazing!
web_1 | Please make sure Mongodb is installed and running!
web_1 |
web_1 | /usr/src/app/node_modules/mongodb/lib/server.js:242
web_1 | process.nextTick(function() { throw err; })
web_1 | ^
web_1 | Error: connect ECONNREFUSED 127.0.0.1:27017
web_1 | at Object.exports._errnoException (util.js:837:11)
web_1 | at exports._exceptionWithHostPort (util.js:860:20)
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
web_1 |
web_1 | npm ERR! Linux 4.4.15-moby
web_1 | npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "start:prod"
web_1 | npm ERR! node v4.0.0
web_1 | npm ERR! npm v2.14.2
web_1 | npm ERR! code ELIFECYCLE
web_1 | npm ERR! [email protected] start:prod: `cross-env NODE_ENV=production node index.js`
web_1 | npm ERR! Exit status 1
web_1 | npm ERR!
web_1 | npm ERR! Failed at the [email protected] start:prod script 'cross-env NODE_ENV=production node index.js'.
web_1 | npm ERR! This is most likely a problem with the mern-starter package,
web_1 | npm ERR! not with npm itself.
web_1 | npm ERR! Tell the author that this fails on your system:
web_1 | npm ERR! cross-env NODE_ENV=production node index.js
web_1 | npm ERR! You can get their info via:
web_1 | npm ERR! npm owner ls mern-starter
web_1 | npm ERR! There is likely additional logging output above.
web_1 |
web_1 | npm ERR! Please include the following file with any support request:
web_1 | npm ERR! /usr/src/app/npm-debug.log
web_1 |
web_1 | npm ERR! Linux 4.4.15-moby
web_1 | npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "bs"
web_1 | npm ERR! node v4.0.0
web_1 | npm ERR! npm v2.14.2
web_1 | npm ERR! code ELIFECYCLE
web_1 | npm ERR! [email protected] bs: `npm run clean && npm run build && npm run build:server && npm run start:prod`
web_1 | npm ERR! Exit status 1
web_1 | npm ERR!
web_1 | npm ERR! Failed at the [email protected] bs script 'npm run clean && npm run build && npm run build:server && npm run start:prod'.
web_1 | npm ERR! This is most likely a problem with the mern-starter package,
web_1 | npm ERR! not with npm itself.
web_1 | npm ERR! Tell the author that this fails on your system:
web_1 | npm ERR! npm run clean && npm run build && npm run build:server && npm run start:prod
web_1 | npm ERR! You can get their info via:
web_1 | npm ERR! npm owner ls mern-starter
web_1 | npm ERR! There is likely additional logging output above.
web_1 |
web_1 | npm ERR! Please include the following file with any support request:
web_1 | npm ERR! /usr/src/app/npm-debug.log
maroon_web_1 exited with code 1
謝謝,就是這樣。我在代碼中有一個env變量,然後刪除它,選擇一個直接的連接字符串。 – user1775718