How To Set up and Configure Redis on Ubuntu 18.04

Redis is an open-source in-memory information construction retailer. It may be used as a database, cache and message dealer and helps varied information buildings akin to Strings, Hashes, Lists, Units and many others. Redis gives excessive availability through Redis Sentinel together with monitoring, notifications Automated failover. It additionally gives computerized partitioning throughout a number of Redis nodes with Redis Cluster.

This tutorial describes the way to set up and configure Redis on an Ubuntu 18.04 server. The identical directions apply for Ubuntu 16.04 and any Ubuntu-based distribution.


Earlier than beginning with the tutorial, ensure you are logged in as a person with sudo privileges.

Putting in Redis on Ubuntu

Redis package deal is included within the default Ubuntu 18.04 repositories. The set up is fairly easy, simply comply with the steps beneath:

  1. Begin by updating the apt packages checklist by operating the next command in your SSH terminal:

  2. Set up Redis by typing:

    sudo apt set up redis-server

  3. As soon as the set up is accomplished, the Redis service will begin routinely. To verify the standing of the service, enter the next command:

    sudo systemctl standing redis-server

    You must see one thing like this:

    ● redis-server.service – Superior key-value retailer
    Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
    Lively: lively (operating) since Solar 2018-10-28 05:10:45 PDT; 2h in the past
    Course of: 2197 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, standing=0/SUCCESS)
    Course of: 2201 ExecStart=/usr/bin/redis-server /and many others/redis/redis.conf (code=exited, standing=0/SUCCESS)
    Foremost PID: 2226 (redis-server)
    Duties: 4 (restrict: 2319)
    CGroup: /system.slice/redis-server.service
    `-2226 /usr/bin/redis-server

Redis service will fail to start out if IPv6 is disabled in your server.

Congratulations, at this level you’ve Redis put in and operating in your Ubuntu 18.04 server.

Configure Redis Distant Entry

By default, Redis doesn’t enable distant connections. You may hook up with the Redis server solely from (localhost) – the machine the place Redis is operating.

Carry out the next steps solely if you wish to hook up with your Redis server from distant hosts. In case you are utilizing a single server setup, the place the appliance and Redis are operating on the identical machine then you shouldn’t allow distant entry.

To configure Redis to just accept distant connections open the Redis configuration file along with your textual content editor:

sudo nano /and many others/redis/redis.conf

Find the road that begins with bind ::1 and change with

/and many others/redis/redis.conf

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind ::1

Save the file and shut the editor.

Restart the Redis service for modifications to take impact:

sudo systemctl restart redis-server

Use the next command to confirm that redis is listening on all interfaces on port 6379:

You must see one thing like beneath. 0.0.0.Zero means all IPv4 addresses on the machine.

tcp LISTEN 0 128*
tcp LISTEN 0 128 [::]:6379 [::]:*

Subsequent, you’ll want so as to add a firewall rule that permits site visitors out of your distant machines on TCP port 6379.

Assuming you might be utilizing UFW to handle your firewall and also you need to enable entry from the subnet you’ll run the next command:

sudo ufw enable proto tcp from to any port 6379

At this level, Redis server will settle for distant connections on TCP port 6379.

Ensure your firewall is configured to just accept connections solely from trusted IP ranges.

To confirm that all the things is about up correctly, you’ll be able to attempt to ping the Redis server out of your distant machine utilizing the redis-cli utility:

redis-cli -h <REDIS_IP_ADDRESS> ping

The command ought to return a response of PONG:


Congratulations, you’ve efficiently put in Redis in your Ubuntu 18.04 server. To seek out extra details about the way to handle your Redis set up go to the Redis documentation web page.


Germany Devoted Server

Leave a Reply