Connecting to Redis from localhost - python

I am using ElastiCache for Redis on AWS. But, I'm not able to connect to Redis from localhost. I have used the endpoint on AWS. It always shows connection timed out. Is there a way to make it work?

The first thing you should make sure is the VPC Security Group that the Elasticache Redis is attached, allows Custom TCP traffic from your address to port number 6379 (default for Redis).
For me the connection timed out issue arised due to the inaccessibility to the VPC where the Redis cluster resides.

Check your security group of Elastic cache cluster. It should allow port 6379 from the EC2 instance. You can allow your EC2 instance's security group in Elastic cache security group to access port 6379.

You can't connect AWS ElastiCache Redis outside of your VPC network or from your laptop. You have to go through tunnel to connect redis from your laptop.
As elaticache redis is not avaiable to outside network that's why you are getting timeout error because redis couldn't find the aws elasicache host.
You can easily connect to aws elaticache redis with in aws vpc, without any timeout error.
My suggestion is use your localhost to connect redis in your laptop for development and use aws elasticache redis host/port to connect inside aws server.

Related

How to connect to GCP Memorystore redis from local?

I am able to access GCP Memorystore Redis from gcp cloud run through vpc connector. But how can I do that from my localhost ?
You can connect from a localhost machine with port forwarding and it can be helpful to connect to your Redis instance during development.
Create a compute engine instance by running the following command:
gcloud compute instances create NAME --machine-type=f1-micro --zone=ZONE
Open a new terminal on your local machine.
To create an SSH tunnel that port forwards traffic through the Compute Engine VM, run the following command:
gcloud compute ssh COMPUTE_VM_NAME --zone=ZONE -- -N -L 6379:REDIS_INSTANCE_IP_ADDRESS:6379
To test the connection, open a new terminal window and run the following command:
redis-cli ping
The SSH tunnel remains open as long as you keep the terminal window with the SSH tunnel connection up and running.
I suggest you use the link for setting up a development environment.
If you are using Redis as caching-only, or simple pub/sub, I would just spin up a local redis container for development.

Connect Python to kafka on AWS EC2 from local machine

I am trying to connect my python application to kafka running on AWS EC2. I am able to connect with ec2 via terminal i check with telnet <ec2 ip> 9092. I am able to connect via this but not able to connect with python application.
Even if my python application starts with without any error with ec2 ip address, i am not able to receive any data from my kafka topic from ec2 to local machine.
When i add my pulic ip address to:
advertised.listeners=PLAINTEXT://<local ip addrss>:9092
Debezium connector with kafka-connect won't start , but without enabling advertised.listeners it works.
How do i configure kafka and kafka-connect so that i can consume kafka topic from ec2 instance on my local machine?
You need to set advertised.listeners to be the EC2 Public DNS/IP, restart the broker, then open the VPC / firewall connection on the listening port.
Debezium's rest.advertised.listener property is different from Kafka broker's, and you woudn't need it set on your local machine.
Python and Kafka Connect should share the same bootstrap.server protocol
You can test your listeners better using kafkacat -L -b <bootstrap>:9092

Connect Azure Web App to Azure Cache for Redis

How can I connect the Azure Cache for Redis to the Flask WebApp that uses celery to perform some asynchronous tasks? Whenever I try to connect via Webjob, it would say unable to connect to redis.
I also tried enter this celery inspect ping -b redis://{password}#{redis_service_name}.redis.cache.windows.net:6379/0 from this post How to configure celery-redis in django project on microsoft azure? but i would get Connection Failure: If this issue persists, ensure your computer's firewall and proxy settings allow outbound TCP traffic to port 10225. Using the firewall feature on your cache may also block connections from the console if your IP address has not been whitelisted
If there is no special rule in the firewall, this error should not occur. In general, there are special firewall settings in company networks, so access problems can occur. In this case, you need to allow the firewall to port 10225 outbound.
You can test it on a different network using Redis console on Azure to see if it's firewall-related.
using company network with firewall rule
other network without firewall rule
Try switching your network to work temporarily. This is a network specific issue and the port used to connect to Redis server is blocked and needs to be opened.

AWS + MongoDB : How to connect to mongo server on AWS linux instance?

I launched an AWS linux instance and installed and ran mongo as instructed here. The mongo service is running and accepting connections on 27017. However, when I go to the server publik dns with port 27017 the server does not respond and I don't see the default mongo message.
I am trying to run a Python(Flask) server on another instance and trying to connect to the mongo server using the private ip, but the connection does not happen. I get this error message on the terminal :
pymongo.errors.ServerSelectionTimeoutError: xxx.xx.xx.xx:27017: [Errno
111] Connection refused
Is this not the right way to use mongo db on aws ? If this approach is feasible, what is causing the connection to not happen ?
All inputs appreciated, much thanks!
It is possible that your mongodb is configured to only accept connection from local host. Edit /etc/mongod.conf file to comment out the line that bindIP like in the example below -
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.

RDS Postgres, can connect from local but not from EC2

Okay this is a little weird, I have set up an RDS Postgres instance that I'm able to connect from pgAdmin and psql-commandline running locally, but not able to connect from command-line psql or webserver (flask) from the EC2 instance.
I'm guessing it has to do something with outbound connections from EC2 but my security group setting allows all outbound.
FYI: I have setup flask using elasticbeanstalk if that makes any difference.

Categories