Question
Node does not connect with redis
I’ve created a Node droplet and when I “npm start” it (“node server.js” is executed) I get the following error:
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
My redis server is a droplet as well and the redis-server is running. I checked it with “systemctl status redis”. It shows “active (running)”.
I followed this tutorial to set redis up: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04
But I get the following error when starting my backend:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.13.7
3 info using node@v13.10.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle backend@0.1.2~prestart: backend@0.1.2
6 info lifecycle backend@0.1.2~start: backend@0.1.2
7 verbose lifecycle backend@0.1.2~start: unsafe-perm in lifecycle true
8 verbose lifecycle backend@0.1.2~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/user/backend/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/us$
9 verbose lifecycle backend@0.1.2~start: CWD: /home/user/backend
10 silly lifecycle backend@0.1.2~start: Args: [ '-c', 'node server.js' ]
11 silly lifecycle backend@0.1.2~start: Returned: code: 1 signal: null
12 info lifecycle backend@0.1.2~start: Failed to exec start script
13 verbose stack Error: backend@0.1.2 start: `node server.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:316:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:316:20)
13 verbose stack at maybeClose (internal/child_process.js:1026:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid backend@0.1.2
15 verbose cwd /home/user/backend
16 verbose Linux 4.15.0-66-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v13.10.1
19 verbose npm v6.13.7
20 error code ELIFECYCLE
21 error errno 1
22 error backend@0.1.2 start: `node server.js`
22 error Exit status 1
23 error Failed at the backend@0.1.2 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Thanks for every help!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×