PING to check that the connection and the server are alive.
Without arguments the server replies PONG. With a message it echoes that message back instead, which lets a client match a reply to the exact request that produced it. PING is the standard health check for a connection pool, both to test a connection before handing it out and to keep an otherwise idle connection from being closed by intermediate proxies. It also works while the connection is subscribed to channels, where it doubles as a keepalive.
Syntax
Arguments
Important points
- Without arguments the reply is
PONG; with a message, the message is echoed back as a bulk string. - While the connection is subscribed under RESP2,
PINGreplies with a two-element array holdingpongand the message instead.
Response
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
upstash_redis
upstash_redis
ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs