Upstash Documentation

PING

Ping the server.
2 min read

Use 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#

ArgumentRequiredRepeatableDescription
<message>NoNoMessage payload.

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, PING replies with a two-element array holding pong and 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.

ProtocolReply
RESP2Simple string PONG, or the message as a bulk string; a two-element pong/message array while subscribed
RESP3Simple string PONG, or the message as a bulk string
Note

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 TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs