Error: failed to connect to [localhost:27017]
See original GitHub issuebug?*
What is the current behavior?
i type : npm start at my code dir
If the current behavior is a bug, please provide the steps to reproduce.
0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'start' ] 2 info using npm@3.10.10 3 info using node@v6.11.2 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle passport-mongo@0.0.1~prestart: passport-mongo@0.0.1 6 silly lifecycle passport-mongo@0.0.1~prestart: no script for prestart, continuing 7 info lifecycle passport-mongo@0.0.1~start: passport-mongo@0.0.1 8 verbose lifecycle passport-mongo@0.0.1~start: unsafe-perm in lifecycle true 9 verbose lifecycle passport-mongo@0.0.1~start: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/ahmad/Desktop/DashBord3/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin 10 verbose lifecycle passport-mongo@0.0.1~start: CWD: /home/ahmad/Desktop/DashBord3 11 silly lifecycle passport-mongo@0.0.1~start: Args: [ '-c', 'node ./bin/www' ] 12 silly lifecycle passport-mongo@0.0.1~start: Returned: code: 1 signal: null 13 info lifecycle passport-mongo@0.0.1~start: Failed to exec start script 14 verbose stack Error: passport-mongo@0.0.1 start:
node ./bin/www14 verbose stack Exit status 1 14 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at EventEmitter.emit (events.js:191:7) 14 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at ChildProcess.emit (events.js:191:7) 14 verbose stack at maybeClose (internal/child_process.js:891:16) 14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 15 verbose pkgid passport-mongo@0.0.1 16 verbose cwd /home/ahmad/Desktop/DashBord3 17 error Linux 4.4.0-89-generic 18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "start" 19 error node v6.11.2 20 error npm v3.10.10 21 error code ELIFECYCLE 22 error passport-mongo@0.0.1 start:
node ./bin/www22 error Exit status 1 23 error Failed at the passport-mongo@0.0.1 start script 'node ./bin/www'. 23 error Make sure you have the latest version of node.js and npm installed. 23 error If you do, this is most likely a problem with the passport-mongo package, 23 error not with npm itself. 23 error Tell the author that this fails on your system: 23 error node ./bin/www 23 error You can get information on how to open an issue for this project with: 23 error npm bugs passport-mongo 23 error Or if that isn't available, you can get their info via: 23 error npm owner ls passport-mongo 23 error There is likely additional logging output above. 24 verbose exit [ 1, true ]
> passport-mongo@0.0.1 start /home/ahmad/Desktop/DashBord3
node ./bin/www
events.js:160 throw er; // Unhandled ‘error’ event ^
Error: failed to connect to [localhost:27017]
at .<anonymous> (/home/ahmad/Desktop/DashBord3/node_modules/mongodb/lib/mongodb/connection/server.js:555:25)
at emitThree (events.js:116:13)
at emit (events.js:194:7)
at .<anonymous> (/home/ahmad/Desktop/DashBord3/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at emitTwo (events.js:106:13)
at emit (events.js:191:7)
at Socket.<anonymous> (/home/ahmad/Desktop/DashBord3/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1277:8)
ahmad@indra-PC:~$ mongo
MongoDB shell version: 3.0.15
connecting to: test
2017-12-08T12:59:44.636+0200 W NETWORK Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-12-08T12:59:44.638+0200 E QUERY Error: couldn’t connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
ip table
`ahmad@indra-PC:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp – localhost.localdomain anywhere tcp dpt:27017 state NEW,ESTABLISHED
Chain FORWARD (policy ACCEPT) target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all – anywhere anywhere
ACCEPT tcp – anywhere localhost.localdomain tcp spt:27017 state ESTABLISHED
**Please mention your node.js : npm@3.10.10 , mongoose : passport-mongo@0.0.1 /home/ahmad/Desktop/DashBord3 └── mongoose@3.8.23 invalid npm ERR! invalid: mongoose@3.8.23 /home/ahmad/Desktop/DashBord3/node_modules/mongoose
MongoDB version. : db version v3.0.15 git version: b8ff507269c382bc100fc52f75f48d54cd42ec3b **
Issue Analytics
- State:
- Created 6 years ago
- Comments:13
try 127.0.0.1 instead of localhost in your connection string. i.e. “mongodb://127.0.0.1:27017/database_name”