How can you make your local Django development server think it's running inside your AWS network using SSH tunneling?
My scenario, I'm running a local Django server i.e. python manage.py runserver
and Redis as cache backend (Elasticache). When my app runs in the AWS environment it has access to Elasticache, but, Locally it won't (and that's a good thing). If for some reason I want to test my local environment with Elasticache I need to somehow use SSH tunneling to make AWS think it's running inside the VPC network.
I've tried to get this working by using below. I've confirmed I can connect locally using SSH tunneling with Redis Desktop Manager so 100% I know AWS supports this, my problem is now doing the same thing with Django.
This is what I've tried:
> python manage.py runserver 8000
> ssh -i mykey.pem [email protected] -L 6379:localhost:6379
I get the message "Error 60 connecting to" message when I visit http://127.0.0.1:8000/
.
What I'm I doing wrong here?
Notes:
[email protected]
is not the Redis server, just another
EC2 instance on AWS that has access Elasticache that I want to use as a
tunnel. mykey.pem
has access and the correct permission.ssh -i mykey.pem [email protected] -L 6379:localhost:6379
This will forward requests from your local machine (on :6379) to localhost:6379
on the EC2 instance. This is not what you want (unless you have redis running locally on the EC2 instance)
You should use the Elasticache IP instead
ssh -i mykey.pem [email protected] -L 6379:<elasticache-ip>:6379
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With