Start a Redis Server

Before connecting Node.js to Redis, ensure that a Redis server is running.

You can use a local Redis installation or a managed Redis service.

For local development, Docker provides a convenient way to start Redis.

Run the following command:

docker run -d --name socket-chat-redis -p 6379:6379 redis:7-alpine

Verify that the container is running:

docker ps

Test the Redis connection:

docker exec -it socket-chat-redis redis-cli ping

Expected response:

PONG

The example uses a local development container without authentication. Never expose this Redis instance publicly.

Redis Security

This command is intended only for local development. Production Redis should use authentication, TLS where appropriate, private networking, and firewall restrictions.

Start Redis with Docker
docker run -d --name socket-chat-redis -p 6379:6379 redis:7-alpine

Starts Redis in a Docker container and maps port 6379 to the host machine.

Key Takeaways
  • Redis must be running before the adapter connects.

  • Docker simplifies local Redis setup.

  • Never expose an unsecured Redis instance to untrusted networks.