Tech Monger

Programming, Web Development and Computer Science.

Skip to main content| Skip to information by topic

Configure Redis to Accept Remote Connections

If you want to access redis database from remote client or even server then you would need to configure redis to accept remote connection by binding server IP Address.

Learn how to install redis server on Linux and Windows.


Redis Configuration - Remote Connections

As good security practice redis by default does not allow remote client to connect to the server. This configuration can be overridden with following steps.

  1. Get Public IP Address of Redis Server
  2. You can use command like ifconfig on linux and ipconfig on windows to find IP address of your server. Below you can see public ip address of the redis server tagged under inet address which is 93.184.216.34

    ifconfig
    bash-4.2$ ifconfig
    ....
    inet 93.184.216.34
    .....
    

    Note that your machine running redis server must have public ip address, if it is running behind NAT then it will not be to listen for remote connections.

  3. Get Port 6379 Opened If blocked.
  4. By default redis server listen on the tcp port 6379. This port is ephemeral port (non privileged) and should be open for external communication for non root (non admin) users. But incase your network admin has blocked this port then you would need to get it opened by changing firewall rules. Consult with your system or network admin to change firewall rule.

  5. Change redis configuration to bind IP address.
    1. Move to the redis server installation directory.
      cd /home/techmonger/redis/redis-4.0.11/
      
    2. Open redis configuration file redis.conf (Linux) or redis.windows.conf (Windows)
    3. Uncomment following line and bind IP address of your redis server.
      Default Configuration
      # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
      # JUST COMMENT THE FOLLOWING LINE.
      # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #bind 127.0.0.1
      
      Configuration after Enabling Remote Access with Bind
      bind 127.0.0.1 93.184.216.34
      
    4. Start the redis instance with configuration file.
      • Start Redis Server - Linux
        cd /home/techmonger/redis/redis-4.0.11/src/
        ./redis-server ../redis.conf
        
      • Start Redis Server - Windows
        cd C:\Users\techmonger\Documents\Programs
        redis-server.exe redis.windows.conf
        
  6. Secure Remote Access with Password
  7. With above configuration any client on the internet will be able to connect to the redis server. It is important to have an authentication mechanism enabled by setting strong password and then connect to the redis database remotely.


Conclusion

We have learned how to bind server IP address and expose redis database which can be accessed from outside local machine on which it is running.

Tagged Under : Linux Open Source Redis Windows