I have an API in AWS that cannot connect to SQL Server (different EC2 instances)
- I am able to connect to the database using SSMS on my laptop, and the API is using the same connection string
- Both EC2 instances are in the same region and availability zone
- The SQL Server instance is using the SQL-Server-Default VPC security group
- I added the AdministratorAccess policy to the API’s EC2 instance profile role (just to rule out a permissions issue)
I am getting the standard SQL Server error: "A network-related or instance-specific error occurred while establishing a connection to SQL Server"
What am I missing? (Note that I do not want to place SQL Server on the API’s EC2 instance.)
2
Answers
I figured it out! On the RDS dashboard -> Connectivity & Security tab, I had to establish a "EC2 Resource Connection". :)
Ensure security group allows inbound connections on SQL Server port. Check Network ACLs for potential traffic blocks. Confirm SQL Server allows remote connections and has TCP/IP enabled. Verify DNS resolution for SQL Server hostname. Double-check SQL Server Authentication credentials. Use telnet to test connection on port 1433, check SQL Server logs, and consider disabling Windows Firewall if active. These steps will help diagnose the connection issue between your AWS API and SQL Server on separate EC2 instances.