Bobcares

Redis CLI – Connect to a Remote Server with password

by | Jun 20, 2024

Learn how to use Redis CLI to connect to a remote server with a password. Our Redis Support team is here to help you with your questions and concerns.

Redis CLI – How to connect to a Remote Redis Server with password

If you are looking for a little help with enabling remote connections to a Redis Instance, you have come to the right place.

In our development environment, we can allow remote access to the database for tasks like editing, viewing, and removing data. Additionally, we can extend this capability to the Redis instance with a few configuration tweaks.

Our experts have put together this guide to help you enable remote connections to your Redis server.

  1. Method 1: Via Redis Configurations
  2. Method 2:Using the Host and Port (Redis-CLI)
  3. Method 3: Using a Single URI Option (Redis-CLI)

Method 1: Via Redis Configurations

  1. First, open the Redis configuration file as seen here:

    sudo nano /etc/redis/redis.conf

  2. Then, locate the line that says `bind 127.0.0.1` and replace it with:
    bind 0.0.0.0

  3. After that, locate the line `protected-mode yes` and change it to:

    protected-mode no

  4. By default, Redis uses port 6379. So, we have to configure the firewall to allow traffic on this port. Hence run these commands:

    sudo ufw allow 6379
    sudo ufw allow 6379/tcp

    We can replace `6379` with the port number we are using.

  5. Then, restart the Redis service:

    sudo systemctl stop redis
    sudo systemctl start redis

Method 2: Using the Host and Port (Redis-CLI)

In a real-world scenario, your Redis server might be hosted on a remote cloud service like Amazon Web Services (AWS). We can connect to it using the `redis-cli` tool, either from our terminal or through client libraries.

Redis CLI – How to connect to a Remote Redis Server with password

The `redis-cli` provides various options to connect to a remote Redis server.

If the Redis server is hosted at `ch987.cache.amazonaws.com` on port `6379`, we can connect with:

redis-cli -h ch987.cache.amazonaws.com -p 6379

Furthermore, if the instance is secured with a password, use the `-a` option:

redis-cli -h ch987.cache.amazonaws.com -p 6379 -a password

Now, consider an instance with IP address `91.102.91.7` on port `6379`:

redis-cli -h 91.102.91.7 -p 6379

In case the instance is password-protected with `mypassword`:

redis-cli -h ch987.cache.amazonaws.com -p 6379 -a mypassword

Method 3: Using a Single URI Option (Redis-CLI)

We can also connect using a single URI string. For example, if your Redis instance requires a password:

redis-cli -u redis://password@host:port

We can also include both username and password:

redis-cli -u redis://username:password@host:port

For example, if the Redis instance is at `ch987.cache.amazonaws.com` on port `6379`, secured with `mypassword`:

redis-cli -u redis://mypassword@ch987.cache.amazonaws.com:6379

Furthermore, if the username is `myusername` and the password is `mypassword`:

redis-cli -u redis://myusername:mypassword@ch987.cache.amazonaws.com:6379

By following these steps and methods, we can easily enable and manage remote connections to our Redis instance, whether it’s for development purposes or in a production environment.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

By following the above methods, we can easily enable and manage remote connections to our Redis instance, whether it’s for development purposes or in a production environment.
In brief, our Support Experts demonstrated how to enable remote Connections to Redis with a password via Redis CLI.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF