Using homebrew to install Redis but when i try to ping to Redis it show this error.
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Note : I try to turn off firewall and edit conf file also cannot. I using macOS Sierra and homebrew version 1.1.11
First you need to up/start the all the redis nodes using below command, one by one for all conf files. @Note : if you are setting up cluster then you should have 6 nodes, 3 will be master and 3 will be slave.redis-cli will automatically select master and slave out of 6 nodes using --cluster command as shown in my below commands.
then run
output of above should be like:
2nd way to set up all things automatically: you can use utils/create-cluster scripts to set up every thing for you like starting all nodes, creating cluster you an follow https://redis.io/topics/cluster-tutorial
Thanks
If aftre install you need run
redis
on all time, Just type in terminal:redis-server &
Running redis using upstart on Ubuntu
I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed
redis
onto the box and here's how I did it and some things to look out for.To install:
That will create a
redis
user and install theinit.d
script for it. Sinceupstart
is now the replacement for using init.d, I figure I should convert it to run usingupstart
.To disable the default
init.d
script forredis
:Then create
/etc/init/redis-server.conf
with the following script:What this is is the script for
upstart
to know what command to run to start the process. The last line also tellsupstart
to keep trying to respawn if it dies.One thing I had to change in
/etc/redis/redis.conf
is to changedaemonize yes
todaemonize no
. What happens if you don't change it is thatredis-server
will fork and daemonize itself, and the parent process goes away. When this happens,upstart
thinks that the process has died/stopped and you won't have control over the process from withinupstart
.Now you can use the folowing commands to control your
redis-server
:Hope this was helpful!
In my case, it was the password that contained some characters like
'
, after changing it the server started without problems.I just had this same problem because I had used improper syntax in my config file. I meant to add:
maxmemory-policy allkeys-lru
to my config file, but instead only added:
allkeys-lru
which evidently prevented Redis from parsing the config file, which in turn prevented me from connecting through the cli. Fixing this syntax allowed me to connect to Redis.
I found this question while trying to figure out why I could not connect to redis after starting it via
brew services start redis
.tl;dr
Depending on how fresh your machine or install is you're likely missing a config file or a directory for the redis defaults.
You need a config file at
/usr/local/etc/redis.conf
. Without this fileredis-server
will not start. You can copy over the default config file and modify it from there withYou need
/usr/local/var/db/redis/
to exist. You can do this easily withFinally just restart redis with
brew services restart redis
.How do you find this out!?
I wasted a lot of time trying to figure out if redis wasn't using the defaults through homebrew and what port it was on. Services was misleading because even though
redis-server
had not actually started,brew services list
would still show redis as "started." The best approach is to usebrew services --verbose start redis
which will show you that the log file is at/usr/local/var/log/redis.log
. Looking in there I found the smoking gun(s)or
Thankfully the log made the solution above obvious.
Can't I just run
redis-server
?You sure can. It'll just take up a terminal or interrupt your terminal occasionally if you run
redis-server &
. Also it will putdump.rdb
in whatever directory you run it in (pwd
). I got annoyed having to remove the file or ignore it in git so I figured I'd let brew do the work with services.It's the better way to connect to your redis.
At first, check the ip address of redis server like this.
The result is kind of " redis 1184 1 0 .... /usr/bin/redis-server 172.x.x.x:6379
And then you can connect to redis with -h(hostname) option like this.