Not able to connect to AWS RDS SQL Server - sql-server

I am getting the below error when trying to connect to RDS SQL Server database:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Configuration of AWS is as follows:
I have a vpc which has a public subnet and a private subnet. The private subnet has two ec2 instances and both the ec2 instances has the same security group. I am able to connect to rds instance with one ec2 instance but getting the above error when trying to connect with the second ec2 instance. All the resources have the same availability zone.
I have tried below options but not able to resolve the issue:
I have tried adding the IP address of the ec2 instance in the rds server's security group directly but that is not helping.
I have disabled the firewall and anti-virus but it is not making any difference.
I have telnet from the ec2 instance to the rds server on port 1433 and I am not able to connect. So it looks like the issue is with a firewall or security group.
I have checked Network ACLS but we don't have any specific ACL set up. It just has default rules which are not blocking any traffic.
I have double-checked everything (security group, network ACL, DNS name of the server, credentials) but not able to figure this out. Please help me to get this fixed.

Related

AWS Schema Conversion Tool to Connect to SQL Server on localhost

Background
I have a SQL Server database on my machine, using mixed mode auth and SQL users setup on the database and mapped. When connecting via .NET app, I am able to use both windows auth and sql auth without issues. However when connecting via AWS Schema Migration tool, I am not able to connect.
Checks done:-
SQL Server Browser Service running
Port mapping left to default (1433)
TCP/IP pipeline enabled
Done both sql and windows auth
Instance name given via ##servername command as per SCT doc
Windows user given dbo and serveradmin permissions at global level
and also granted Login and DB engine connect
Ignoring the port no
Ignoring the instance name
Unable to check firewall as both SQL and tool running on same machine
Using same SCT config, I can connect to SQL Server elsewhere so drivers seem to be working.
Log message below
When only localhost provided
com.amazon.sct.dbloader.DbLoaderHandledException: Connection wasn't established. Check connection properties.
java.util.concurrent.ExecutionException: com.amazon.sct.dbloader.DbLoaderHandledException: Connection wasn't established. Check connection properties.
When name provided for machine and instance
Connection to 'jdbc:sqlserver://localhost\DESKTOP-N01JO12:1433' wasn't established. ERROR: code: 0; message: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
LOADER ERROR Error chain:
The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."
Screenshots
For AWS SCT can access SQL server, the following conditions need to be satisfied:
DB has login account and user
User have to has admin role
SQL server authentication enabled
TCP/IP cho SQL server enabled
1. DB has login account and user
You can reference in this link:
https://www.guru99.com/sql-server-create-user.html
2. User have to has admin role
You can reference in this link: https://tableplus.com/blog/2018/10/how-to-create-user-with-admin-access-in-sql-server.html
3. SQL server authentication enabled
You can reference in this link:
SqlServer: Login failed for user
Note: Remember to restart SQL server
4. TCP/IP cho SQL server enabled
You can reference in this link: https://www.youtube.com/watch?v=p9mv2RP6Tck
==> Conclusion
I see you do all the think above
Here is my connection information for SQL server on my EC2 windows server
(I can't embed picture because I don't have enough reputation point)
Perhaps you should write connection information like me
Hope this help!

Connecting to Azure DB from SQL management studio is failing MSSQLSERVER_10060

I'm trying to connect to the sql server that has been created on Azure using SQL management studio, but i'm getting the following error.
Error message: An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
I have enabled the client IP in the SQL server firewall settings.
Please let me know if anything else need to be taken cared. Thank you
To resolve this error, try one of the following actions:
Make sure that you have configured the firewall on the computer to allow this instance of SQL Server to accept connections. That is, If you are trying to connect from within a corporate network, outbound traffic over port 1433 may not be allowed by your network's firewall. If so, you cannot connect to your Azure SQL Database server unless your IT department opens port 1433. On the Azure Side, you also need to check if the NSG (associated with that subnet the Azure SQL server sitting in) allows the client IP with the specific port 1433.
Add the client IP in the SQL server firewall settings if you enable a server-level firewall.
Telnet the current IP of your Azure SQL Database server with the port to verify the network connection.
Ensure the server name you are connecting to is correct.
Check that your own firewall allows your connection across the internet to the instance.
Typically if it was the Azure firewall side, it would prompt you to add your IP to the firewall rules, provided you're connecting with an admin account.
This cause by network restriction in your lan. you can try by switching your network connnection. It worked for me.

Unable to connect on AWS - RDS DB : SQL Server 2012 Express

I'm new in AWS world. I have an issue to access to my instance of Microsoft SQL Server 2012 Express (11.00.5058) on RDS (US-East-1a).
When I have created DB instance, I was able to access to it, create some tables, transfer data, etc.. everything worked fine !
I didn't change anything and few hours after some inactivity, I try to access to the SQL Server instance by using Microsoft SQL Server Enterprise Manager but I was not able to connect to it anymore. I got following message:
Cannot connect to m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com,1433.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The wait operation timed out.) (Microsoft SQL Server, Error: 258)
Currently, instance appears as available, the security group is 'rds-launch-wizard (sg-be4afcc6)'.
I have try to connect to 1433 port on via Telnet and no success.
Instance name is m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com.
Do you have any idea what append ?
Thank a lot for your help.
UPDATED
Telnet command return this :
telnet m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com 1433
Connecting To m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com...
Could not open connection to the host, on port 1433: Connect failed
DB settings :
Security Group :
VPC :
I have tried to connect by using my home connection, or coffee shop wifi without success. I didn't check what was my IP address at this moment but the strange thing is that I was able to connect to SQL server when I have created DB instance (create SQL table, transfer data, etc...) but after few hours (and without any change), I was not able to access to it.
May be if I add a new rule in security group / inbound rule like this,it will fix my issue : (i didn't try yet because I'm at work right now and we have firewall that block SQL access)
At this point, data are not sensitive and security is not a big issue.
Thank again for your help guys !!!
This because maybe you choose the default group , so Edit Your Security Group And In (INBOUND) ADD RULE and allow connection from (ANYWHERE)
Actions
Edit inbounds rules
MS SQL TCP 1433 My Ip (Automatically appears the public ip of your router)
Save
Try connect

Why can't I connect my website to a SQL Server database hosted on another computer via its public ip

I have a website hosted on a shared server, and I have setup on server to allow remote connection, and also turned on to allow remote connections.
Also I have turned the firewall off.
I am able to log in to my SQL Server via our static ip and port from a different computer not on our network from SQL Server Management Studio, and also when I run my website on my local host,
But when I publish our website to our hosted server it will not connect to our database and return an error :
[Win32Exception (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions][SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An attempt was made to access a socket in a way forbidden by its access permissions.)]
This is our connection string
Data Source=000.000.00.00,12341;Integrated Security=False;
User ID=myUserNmae;password=myPassword;Initial Catalog=dBaseName;
What else could be wrong here?
you may have to open the program, not (simply) the port
http://technet.microsoft.com/en-us/library/cc646023.aspx
To add a program exception to the firewall using the Windows Firewall item in Control Panel.
On the Exceptions tab of the Windows Firewall item in Control Panel, click Add a program.
Browse to the location of the instance of SQL Server that you want to allow through the firewall, for example C:\Program Files\Microsoft SQL Server\MSSQL11.<instance_name>\MSSQL\Binn, select sqlservr.exe, and then click Open.
Click OK.
You'll want to read especially about "Dynamic Ports"
http://technet.microsoft.com/en-us/library/cc646023.aspx#BKMK_dynamic_ports
Can you try:
Data Source=127.0.0.1,12341;Integrated Security=False;
User ID=myUserNmae;password=myPassword;Initial Catalog=dBaseName;
Does the machine have an internal and external IP ? Aka, you may have to use the internal-IP (a real one, not just 127.0.0.1) for the IP address in the connection string.
to update you all if this issue might happen to you as well .
my website is hosted as shared hosting by hostgator and they claim that for security they will only allow traffic for sql to be done only via port 1433, which is the default port for sql...
hope this helps someone in the future

How to make SQL Server running in Virtual PC accessible to host OS?

I'm running SQL Server 2008 Express on Windows XP on a VirtualPC instance inside a Windows XP host. I want to be able to connect to databases on the guest instance using SSMS on the host. When I go to connect from SSMS on the host, and browse for servers, I see the instance of SQL Server on the guest. Yet when I try to connect, using a SQL authentication login, I get the following connection error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 28 - Server doesn't support requested protocol) (Microsoft SQL Server, Error: -1)
I have:
* tried connecting with both Name Pipes and TCP/IP
* ensured that the SQL Browser service is up
* ensured that the firewall on the guest is open
* the server is configured to allow remote connections (according to the database engine properties within SSMS on the guest)
What am I missing?
EDIT: I figured this out. My resolution is below.
SELF-ACCEPTED ANSWER
Thanks for the ideas. After much fiddling I got things working. It turned out that I had not gone into the Sql Server Configuration Manager and enabled TCP/IP and Named Pipes as network protocols. So even though SSMS said remote connections were enabled, there was no protocol to allow for them other than shared memory. After I did this I restarted the SQL Server service, but things still didn't seem to work properly. Yet once I had rebooted both the guest and host, everything was working as expected.
How are your IP settings? Are you sharing the same IP address between the two machines? If so, then perhaps when your clients attempt to connect to 10.1.1.10, it is hitting the IP of the machine hosting the VPC instance, and that machine is not running the SQL Server instance. If possible, have VPC get its own IP and try that.
Mostly double check what you have already said,
turn off the guest firewall to make sure it isn't that.
Make sure your virtual machine networking is set to bridged and not NAT.
Try connecting to the IP address of the guest instead of its name.
Make sure the remote connections are allowed by SQL server and that both client and server are using tcp/ip (or named pipes if you prefer).
I don't know if enabling remote connections requires a restart of SQL server.
Try using SQL authentication to eliminate an authentication issue. Are you running on a domain?
To add some steps that are not explicitly called out above, what worked in my experience was to set up the Virtual PC's Networking to my physical network adapter.
Then disabled Windows Firewall for the Public Profile.
Hopefully could actually lock that down to port 1433.
Also, on the guest OS, if SQL Server is installed with only Windows Auth, you later add SQL auth, note that by default 'sa' is disabled for login access. Either 'enable' Login for 'sa' or (better idea) create Logins with appropriate permissions as needed.

Resources