5

I installed Redis via brew install redis and attempted to add it as a service via:

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

These didn't generate any errors; however, it appears that Redis does not start. If I run redis-cli ping, I get back Could not connect to Redis at 127.0.0.1:6379: Connection refused.

I can manually run redis-server in another terminal window, but I'd like to have Redis auto-start on login.

I also tried uninstalling Redis, reinstalling it, and using brew services to manage services (brew services works fine for me with the installations of MongoDB and Cassandra).

I haven't seen others having this problem so I'm not sure how to diagnose. If anyone has any advice, much appreciated!

John Galt
  • 163
  • 1
  • 4

3 Answers3

6

make sure you've tapped the services first:

brew tap homebrew/services

then try:

brew services [start/stop/restart] redis

you can also start and stop redis with:

sudo launchctl start io.redis.redis-server

sudo launchctl stop io.redis.redis-server

to make your life easier, you can add aliases for these commands to your .bash_profile.

alias redisstart='sudo launchctl start io.redis.redis-server'
alias redisstop='sudo launchctl stop io.redis.redis-server'

then you can just start and stop redis by typing redisstart and redisstop.

another way you can go about this is adding redis as a background service:

sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist

then copy and paste the following into the file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>io.redis.redis-server</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/redis-server</string>
        <string>/usr/local/etc/redis.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
selfagency
  • 211
  • 2
  • 6
1
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
lifecom
  • 11
  • 1
  • 2
    Welcome to Server Fault! It looks like you may have the knowledge to provide good Answer here, but please consider reading [How do I write a good Answer?](http://serverfault.com/help/how-to-answer) in our help center and then revise the Answer. Your Commands/Code/Settings may technically be the solution but some explanation and context is welcome. Thanks in advance. – HBruijn Nov 25 '15 at 10:37
1

You may have edited the conf file to daemonize redis when you used to start redis manually before. Check it and change daemonize to no, then retry brew services

Ian Yang
  • 111
  • 2