Pages

Wednesday, 28 January 2026

How to test Redis connectivity




We first need to check if Redis DNS name resolves:

% nslookup redis.example.com

Server: 192.168.1.1
Address: 192.168.1.1#53

Non-authoritative answer:
redis.example.com canonical name = example-prod-redis-serverless-kg5o59.serverless.use2.cache.amazonaws.com.
example-prod-redis-serverless-kg5o59.serverless.use2.cache.amazonaws.com canonical name = default.example-prod-redis-serverless-kg5o59.serverless.use2.cache.amazonaws.com.
Name: default.example-prod-redis-serverless-kg5o59.serverless.use2.cache.amazonaws.com
Address: 10.0.3.74
...


Let's try to make a TCP connection:

% nc -vz redis.example.com 6379

nc: connectx to redis.example.com port 6379 (tcp) failed: Operation timed out

After adding remote client's IP address to inbound rules of Redis security group (firewall):

% nc -vz redis.example.com 6379

Connection to redis.example.com port 6379 [tcp/*] succeeded!

 
Let's now install Redis client so we can try to connect to the server:

% brew install redis
==> Fetching downloads for: redis
✔︎ Bottle Manifest redis (8.4.0)                                                                                                                                                            Downloaded   10.9KB/ 10.9KB
✔︎ Bottle Manifest ca-certificates (2025-12-02)                                                                                                                                             Downloaded    2.0KB/  2.0KB
✔︎ Bottle ca-certificates (2025-12-02)                                                                                                                                                      Downloaded  131.8KB/131.8KB
✔︎ Bottle redis (8.4.0)                                                                                                                                                                     Downloaded    1.2MB/  1.2MB
==> Installing redis dependency: ca-certificates
==> Pouring ca-certificates--2025-12-02.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /opt/homebrew/Cellar/ca-certificates/2025-12-02: 4 files, 236.4KB
==> Pouring redis--8.4.0.arm64_sequoia.bottle.tar.gz
==> Caveats
To start redis now and restart at login:
  brew services start redis
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf
==> Summary
🍺  /opt/homebrew/Cellar/redis/8.4.0: 15 files, 3MB
==> Running `brew cleanup redis`...
...
==> Caveats
==> redis
To start redis now and restart at login:
  brew services start redis
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf


Let's connect to Redis server and execute ping command (expected response is PONG) and also get some information about the server:


% redis-cli \       
  --tls \
  -h redis.example.com \
  -p 6379

redis.example.com:6379> ping
PONG
redis.example.com:6379> info server 
# Server
redis_version:7.1
redis_mode:cluster
os:Amazon ElastiCache
arch_bits:64
run_id:0
redis.example.com:6379> 


---

No comments:

Post a Comment