Bobcares

How to Fix Error 99 connecting to localhost:6379 in Redis?

by | Oct 22, 2024

The Redis message “Error 99 connecting to localhost:6379. Cannot assign requested address” shows that a connection attempt to the Redis server running on localhost at port 6379 has failed. Let’s discuss on the various causes and fixes of the issue in this article. At Bobcares, with our Server Management Service, we can handle your Redis issues.

Overview
  1. Fixing Redis “Error 99 connecting to localhost:6379”
  2. What are the Impacts of the Redis Error?
  3. What are the Causes & Fixes of the Redis Error?
  4. How to Prevent the Redis Error?
  5. Conclusion

Fixing Redis “Error 99 connecting to localhost:6379”

An unsuccessful attempt to establish a connection to the Redis server operating on localhost at port 6379 is indicated by this message. This error usually appears when the system is unable to bind to the given address and port, which can happen for a number of different reasons. The error’s syntax:

redis error 99 connecting to localhost:6379

Here, the error changes as;

Error 99 connecting to localhost:6379. Cannot assign requested address.

What are the Impacts of the Redis Error?

  • Application Downtime: Apps using Redis for storage or caching may go down or slow down.
  • Task Failures: Systems using Redis for messaging (e.g., Celery) might fail, causing delays.
  • Increased Latency: Apps may respond slower, affecting user experience.
  • Resource Wastage: Repeated retries can waste system resources.

What are the Causes & Fixes of the Redis Error?

1. Redis Server Not Running: The Redis server may be off or has crashed.

Fix:

i. We’ve to check if Redis is running by using: redis-cli ping.

ii. If it doesn’t reply with “PONG,” start it with: redis-server.

2. Incorrect Configuration: The Redis configuration file (redis.conf) might have incorrect settings.

Fix:

i. Open the file (found in /etc/redis/ or /usr/local/etc/redis/).

ii. Ensure the line bind 127.0.0.1 is set correctly.

iii. Save and restart Redis with: sudo systemctl restart redis.

3. Port Already in Use: Another service may be using Redis’s default port (6379).

Fix:

i. Find the process using the port: sudo lsof -i :6379.

ii. Stop the other service or change Redis’s port in redis.conf (e.g., port 6380).

iii. Restart Redis.

4. Firewall Restrictions: Firewalls may block access to port 6379.

Fix:

i. Allow traffic on port 6379 using: sudo ufw allow 6379.

ii. Make sure firewall rules don’t block localhost or Redis’s IP.

5. Network Configuration Issues: Network settings might prevent Redis from binding to localhost.

Fix:

i. Check the /etc/hosts file to ensure localhost is set up correctly.

ii. Test it with: ping localhost.

iii. If needed, add 127.0.0.1 localhost to the file.

6. Resource Constraints: The system may not have enough memory or CPU to run Redis.

Fix:

i. Monitor resources using top or htop.

ii. If resources are low, we must consider upgrading the hardware or optimizing other services to free up space.

7. Docker Misconfiguration: Misconfigured network settings in Docker can cause issues with Redis.

Fix:

i. Ensure Docker is exposing Redis’s ports correctly.

ii. Check the Docker Compose file to make sure Redis and related services (like Celery) share the same network.

iii. Example Docker Compose setup:

services:
redis:
image: redis
ports:
- "6379:6379"
networks:
- mynetwork

networks:
mynetwork:

How to Prevent the Redis Error?

We can use the following steps in order to avoid running into comparable connection problems later on:

  • Frequent Monitoring: To monitor server performance and uptime, we can use third-party solutions or monitoring tools like Redis Monitor.
  • Configuration Management: We must keep record of modifications made to configuration files and keep version control on them.
  • Resource Planning: Find expected load when planning improvements and evaluate resource utilization on a regular basis.
  • Automated Data Backups and Restarts: Assigning services to run automatically in the event of a failure and set up automated data backups is also an easy way.
  • Security Procedures: In order to prevent unwanted access, put in place security measures like firewalls and access controls.
  • Up-to-date Softwares: To take advantage of bug fixes and performance enhancements, we must keep the Redis setup up to current with the most recent stable versions.

[Need to know more? Get in touch with us if you have any further inquiries.]

Conclusion

In summary, the “Error 99 connecting to localhost:6379” in Redis indicates a connection failure due to issues like misconfiguration, port conflicts, or insufficient resources. Addressing this requires checking the server status, verifying configuration files, ensuring no port conflicts, and confirming network settings.

To prevent future issues, our Support Team suggests regular monitoring, proper resource management, and keeping Redis updated as the essential strategies.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.