SQL AWS Connection Error

When I run this code in a python script, I successfully return my database. Why does this not work in anvil?

image

I am guessing a bit here, but whenever I have these issues it’s usually down to an AWS policy that is refusing the connection (which mostly, in my experience, time out as you are seeing above).

The policy might be picking up on some difference between your other python script and the Anvil version, such as maybe origin (ie IP or domain).

1 Like

Hi there, and welcome to the forum!

If you’re getting timeouts, it’s usually because the database has a firewall (or “Security Group” in AWS) that blocks access from Anvil’s servers. You have two options:

  1. Change your firewall rule to allow access from the Anvil egress IP addresses on port 3306 (you can do this from the AWS console – please email support@anvil.works for our latest list of egress IPs)

  2. Use an Uplink script, running on a computer that does have access to the database, to run the SQL commands

I hope this helps!

1 Like

I have added all the egress IP’s into an inbound security group for my EC2 instance. The connection still does not work. Could someone please put out a tutorial for this?

Can you test from your own computer? Eg go to https://whatismyip.com to discover the IP address of the computer you’re browsing from, and (temporarily) add that to the inbound security group. Then you can try connecting with the command-line client, or a local Python script. This will enable you to debug the connections without having to go indirectly via Anvil!

(Also, looking at that error message…this is just a guess, but I think you want to look at the security groups associated with your RDS instance, not EC2!)