Redis from Installation to Operation: A Complete Guide and How to Fix the “Failed listening on port 6379 (tcp)” Error

In modern backend systems, Redis is commonly used as a high-performance cache, message broker, or key–value database that supports large-scale web applications. Thanks to its extremely fast data access speed and in-memory architecture, Redis has become a standard component in many modern system architectures.

However, for beginners, installing and starting Redis may sometimes lead to several common issues. One of the most frequent errors is “Failed listening on port 6379 (tcp), aborting”, which occurs when Redis cannot bind to its default port.

This article walks through the full process of installing Redis, starting the service, verifying its operation, and resolving the port 6379 error in detail.

Understanding Redis and Why It Is Widely Used

Redis is an in-memory data structure store, meaning that data is stored directly in RAM rather than on disk. This allows Redis to achieve extremely fast response times, often within microseconds.

Redis supports several types of data structures, including:

  • Strings
  • Lists
  • Sets
  • Sorted Sets
  • Hashes
  • Streams

Because of these capabilities, Redis can serve many roles in modern applications such as:

  • Caching data for web applications
  • Managing user sessions
  • Handling background task queues
  • Supporting real-time analytics
  • Implementing publish/subscribe messaging systems

The default port used by Redis is 6379, and most applications connect to Redis through this port.

Part 1: Installing Redis on Linux (Ubuntu)

Many production servers run Linux, especially Ubuntu or Debian. Installing Redis on these systems is straightforward.

Step 1: Update the system

Before installing Redis, update the system’s package list:

sudo apt update
sudo apt upgrade

Updating ensures the latest packages are installed and avoids dependency conflicts.

Step 2: Install Redis

Install Redis with the following command:

sudo apt install redis-server

Once installation finishes, Redis will be installed as a system service.

Step 3: Check Redis status

Verify whether Redis is running:

sudo systemctl status redis

If Redis is running correctly, the output will show:

active (running)

Part 2: Starting and Managing Redis

After installation, Redis can be managed using Linux system services.

Start Redis

sudo systemctl start redis

Stop Redis

sudo systemctl stop redis

Restart Redis

sudo systemctl restart redis

Enable Redis to start automatically on boot

sudo systemctl enable redis

This ensures Redis starts automatically when the server reboots.

Part 3: Testing Redis Operation

Redis provides a command-line interface for testing connections.

Run:

redis-cli

Then test with:

ping

If Redis is functioning correctly, the response will be:

PONG

This confirms that the Redis server is active and accepting connections.

Part 4: Common Errors When Starting Redis

One of the most common startup errors is:

Failed listening on port 6379 (tcp), aborting

This error occurs when Redis cannot bind to port 6379.

Typical causes include:

  • Another program is already using port 6379
  • Another Redis instance is already running
  • Incorrect Redis configuration
  • A container or service is occupying the port

Part 5: Checking Whether Port 6379 Is Already in Use

First, identify which process is using the port.

Run:

sudo lsof -i :6379

or

netstat -tulpn | grep 6379

If the port is occupied, the system will show the process ID (PID).

Example output:

redis-server  1234  root  TCP *:6379 (LISTEN)

Part 6: Stopping the Process Using the Port

If another Redis instance is already running, simply stop it:

sudo systemctl stop redis

If another process is using the port:

sudo kill -9 PID

Replace PID with the process ID found earlier.

After stopping the conflicting process, restart Redis:

sudo systemctl start redis

Part 7: Changing the Redis Port (Optional)

In some environments, port 6379 may already be reserved for other services. In this case, you can change Redis to use another port.

Open the configuration file:

/etc/redis/redis.conf

Find the line:

port 6379

Change it to another port, for example:

port 6380

Then restart Redis:

sudo systemctl restart redis

Part 8: Checking the Bind Configuration

Redis may also fail to start if the bind configuration is incorrect.

Open the configuration file:

redis.conf

Find:

bind 127.0.0.1

This configuration allows Redis to listen only on localhost.

If external connections are required, it can be changed to:

bind 0.0.0.0

However, this exposes Redis to external networks and should be configured carefully with proper security measures.

Part 9: Verifying Redis After Fixing the Error

After resolving the issue, verify Redis again:

redis-cli ping

If the response is:

PONG

then Redis is running normally.

Conclusion

Redis is one of the most important tools in modern backend ecosystems. While installation and operation are generally simple, network-related issues—especially the “Failed listening on port 6379 (tcp)” error—can occur if the port is already occupied or if configuration settings are incorrect.

Understanding how to check port usage, manage system services, and edit Redis configuration files will help you quickly resolve these issues and maintain a stable Redis environment.

In large-scale systems, Redis is often deployed with replication, clustering, or sentinel mechanisms to improve availability and scalability, making it a core component of modern infrastructure architectures.