0

I have a ReactJS web app which uses Redis Database. I'm deploying my system on 2 different computers with Ubuntu 16.04. However, I can make the server run with npm start in one computer without any errors, but in the other one, when I use npm start it prompts me with this error:

Redis connection to localhost:6379 failed - connect ECONNREFUSED

So in order to avoid that error, I need to start Redis manually with redis-server , but I don't want to do that. Searched the net for answer but couldn't find a proper solution. So this is my last chance. Thanks for reading ^^

I.K.
  • 414
  • 6
  • 18

2 Answers2

1

You need to add script to start redis-server in your npm start script. Here's sample code -

{
  "name": "test app",
  "version": "1.0.0",
  "scripts": {
    "start": "sh redis-start-script.sh && **your start script**"   
  }
}

You can refer this answer

Vivek
  • 1,465
  • 14
  • 29
1

You can use following script,

"scripts":{ "start": "redis-server --daemonize yes && your start script " }

It will keep your redis server keeps running

arpan das
  • 26
  • 3