2

I installed redis and I am setting it to use a socket.

It works fine at the beginning but if I reboot the machine (ubuntu 14.04 via vagrant on virtualbox), Redis does not start anymore and displays this error in the log: Opening socket: bind: No such file or directory

When I look where the socket file is supposed to be, I understand the error message since the socket file is not there anymore. Actually, the whole /var/run/redis directory does not exist anymore after I reboot.

Here is what I have in my config file:

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 0

bind 127.0.0.1

unixsocket /var/run/redis/0.sock
unixsocketperm 755

Why would the socket file disappear?

Thanks

Michael
  • 471
  • 1
  • 7
  • 14
  • AFAIK A socket only exists as long as the application is listening, it will be recreated when redis restarts. Depending on the Linux distribution /var/run may be cleaned on start-up, including a `mkdir -p /var/run/redis` in the start-up script should solve that – HBruijn Oct 09 '14 at 22:05
  • Oh ok, I thought /var/run was the right place to put the sockets. Where should I put the sockets? In /tmp? – Michael Oct 09 '14 at 22:20

1 Answers1

3

My guess is you are using ubuntu or some distro that mounts /var/run as tmpfs. So each reboot /var/run is cleaned out.

Run mount and if it lists /var/run seperately then that is the case

Mike
  • 22,310
  • 7
  • 56
  • 79
  • You're right, /var/run folder is a symlink to the /run folder and when I run ```mount```, I get ```tmpfs on /run type tmpfs```. Where should I put the socket for redis? I also created a redis user so it has to be somewhere where this user can have access. Thanks – Michael Oct 09 '14 at 22:57
  • best bet is to edit the init script to create the socket file once redis starts – Mike Oct 10 '14 at 02:58