0

I just signed up for the free account on RedisLabs.com. I got the endpoint from their website after getting it set up (by clicking "Database" on left hamburger/drop-down menu), then clicking the "checkbox" to the right of my database/server, then there was a field called "endpoint". Best I can tell, it is up and running; I didn't see and start/stop, or enable/disable. My database (or server?) name is just "Demo"; I don't think I need to specify that in the Python code as long as as I have the endpoint, correct?

I couldn't find any place I was supposed to whitelist IP Addreses, but suspect that might be the issue. Since the host was after the colon on the end, I didn't specify "host=" in my connection in the code below.

My Python test program (I used the endpoint they gave me, but in the code below I just put their sample one).

import redis
import json
import pprint

host_info = "redis.us-east-1-1.ec2.cloud.redislabs.com:18274"
redisObj = redis.Redis(host=host_info, password='xxx')

capitals = {
     "Lebanon": "Beirut",
     "Norway": "Oslo",
     "France": "Paris"
 }
print ("capitals - before call to Redis")
pprint.pprint(capitals)

print ("call to Redis")
redisObj.execute_command('JSON.SET', 'doc', ',', json.dumps(capitals))
print("Data Saved, now fetch data back from redis")
reply = json.loads(redisObj.execute_command('JSON.GET', 'doc'))
print ("reply from Redis get")
pprint.pprint(reply)

Error:

  File "C:\Users\nwalt\.virtualenvs\TDAmeritradeGetQuotes\lib\site-packages\redis\connection.py", line 563, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 11001 connecting to redis.us-east-1-1.ec2.cloud.redislabs.com:18274:6379. getaddrinfo failed.

From the command line, I also tried: redis-cli -h redis.us-east-1-1.ec2.cloud.redislabs.com:18274

It gives error: Could connect to Redis at ..... can't resolve: ....

5
  • try changing the dns maybe? Commented Sep 25, 2020 at 3:33
  • Is that something done on the Redis site? Or do you mean like a hosts file on my computer? Commented Sep 25, 2020 at 3:41
  • on your computer. try changing to use google dns 8.8.8.8 maybe? because the "cannot resolve" seems to be dns related. Commented Sep 25, 2020 at 3:43
  • I'm already using 1.1.1.1 Commented Sep 25, 2020 at 14:32
  • I'm able to connect via Telnet (which is often used to prove if connectivity works) Commented Sep 25, 2020 at 14:39

1 Answer 1

3

I first used

telnet redis.us-east-1-1.ec2.cloud.redislabs.com 18274

to make sure it was not a connectivity issue (many servers have Ping turned off).

On the RedisLabs website, they give you what is called an endpoint that ends with the colon and port number. Apparently, you cannot use that as your host in Python (other tools and products often combine the two), you have to split it up, so for example:

Doesn't work:

host_info = "redis.us-east-1-1.ec2.cloud.redislabs.com:18274"
redisObj = redis.Redis(host=host_info, password='xxx')

Works:

host_info2 = "redis.us-east-1-1.ec2.cloud.redislabs.com"
redisObj = redis.Redis(host=host_info2, port=18274, password='xxx')

I've got another issue to fix on my sample, but I'm not getting connection error any more.

Also see "Basic Connection Troubleshooting" on RedisLabs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.