I have a Nodejs application that I was using Redis for to handle the sessions. I am using connect-redis
npm package. Now, I deployed the same Nodejs app to heroku but I do not know if there is a way to get a Redis server going along side my Nodejs application in Heroku.
I get the following error on heroku logs --tail
2020-04-09T03:40:31.880266+00:00 app[web.1]: throw er; // Unhandled 'error' event 2020-04-09T03:40:31.880267+00:00 app[web.1]: ^ 2020-04-09T03:40:31.880267+00:00 app[web.1]: 2020-04-09T03:40:31.880267+00:00 app[web.1]: Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 2020-04-09T03:40:31.880268+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16) 2020-04-09T03:40:31.880268+00:00 app[web.1]: Emitted 'error' event on RedisClient instance at: 2020-04-09T03:40:31.880268+00:00 app[web.1]: at RedisClient.on_error (/app/node_modules/redis/index.js:341:14) 2020-04-09T03:40:31.880269+00:00 app[web.1]: at Socket. (/app/node_modules/redis/index.js:222:14) 2020-04-09T03:40:31.880269+00:00 app[web.1]: at Socket.emit (events.js:311:20) 2020-04-09T03:40:31.880269+00:00 app[web.1]: at emitErrorNT (internal/streams/destroy.js:92:8) 2020-04-09T03:40:31.880270+00:00 app[web.1]: at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) 2020-04-09T03:40:31.880270+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21) { 2020-04-09T03:40:31.880278+00:00 app[web.1]: errno: 'ECONNREFUSED', 2020-04-09T03:40:31.880279+00:00 app[web.1]: code: 'ECONNREFUSED', 2020-04-09T03:40:31.880279+00:00 app[web.1]: syscall: 'connect', 2020-04-09T03:40:31.880279+00:00 app[web.1]: address: '127.0.0.1', 2020-04-09T03:40:31.880280+00:00 app[web.1]: port: 6379 2020-04-09T03:40:31.880280+00:00 app[web.1]: }
I also added an addon called Heroku Redis but I get the same error message