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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF