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!

3 Answers 3

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>
3
  • Won't this run redis as root? Is that a good idea in a production environment?
    – BM5k
    Apr 14, 2016 at 4:23
  • 1
    This is for local dev. I mean, who has an Xserve really?
    – selfagency
    Apr 16, 2016 at 3:37
  • long live the mac mini server!
    – BM5k
    Apr 16, 2016 at 4:39
1
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
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? 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, 2015 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .