Skip to content

SQL Linked EC2 Server (not RDS): Error locating server/instance specified

0

Issue: Not able to successfully create a SQL linked server to given EC2 server (this is not RDS)

Error Message: "Error Locating Server/Instance Specified"

Notes: Created on AWS Security Group for port 1433

SQL Script: EXEC master.dbo.sp_addlinkedserver @server = 'MyLinkedServer' , @srvproduct='' , @provider='SQLNCLI' , @datasrc='MYSERVER\APRO.ec2-33-333-333-33.us-east-2.compute.amazonaws.com';

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = 'MyLinkedServer' , @useself='False' , @locallogin=NULL , @rmtuser='myusername' , @rmtpassword='mypassword';

-- SQL Linked Server Test Script: returns a list of databases on given server SELECT name FROM MyLinkedServer.master.sys.databases

asked 2 years ago318 views

1 Answer
0

If you're encountering an error when trying to connect to an SQL Server running on an EC2 instance (not RDS), saying "Error locating server/instance specified," there are a few common issues and troubleshooting steps to consider:

  1. Check Network Configuration:

    • Ensure that the EC2 instance running SQL Server has the necessary network configuration. Specifically, check:
      • Security Groups: Ensure the security group associated with the EC2 instance allows inbound traffic on the SQL Server port (default is 1433 for SQL Server).
      • Network ACLs: If you're using Network ACLs in your VPC, verify that they allow inbound/outbound traffic on the SQL Server port.
      • Public vs Private IP: Use the appropriate IP address (public or private) depending on where you're trying to connect from.
  2. SQL Server Configuration:

    • Check the SQL Server Configuration Manager on the EC2 instance to ensure that TCP/IP protocol is enabled and configured to listen on the appropriate IP addresses and ports.
    • Verify that SQL Server Browser service is running, especially if you're using named instances.
  3. Firewall Settings:

    • Check the Windows Firewall settings on the EC2 instance running SQL Server to ensure that it allows inbound connections on the SQL Server port (1433 by default).
  4. Instance Name and Port:

    • If you're using a named instance of SQL Server, ensure that you are specifying the correct instance name and port in your connection string (e.g., ServerName\InstanceName,Port).
  5. SQL Server Authentication:

    • If you're using SQL Server Authentication, verify that the username and password in your connection string are correct and have sufficient permissions to connect to the database.
  6. Testing Connectivity:

    • Use tools like Telnet or PowerShell to test connectivity to the SQL Server port from the machine where you are trying to connect.
  7. DNS Resolution:

    • Ensure that the server name (if using DNS) resolves correctly to the IP address of the EC2 instance. If not, consider using the IP address directly.
  8. Restart Services:

    • Sometimes restarting the SQL Server service or even the EC2 instance itself can resolve connectivity issues, especially if there have been recent configuration changes.

By systematically checking these areas, you should be able to diagnose and resolve the "Error locating server/instance specified" issue when trying to connect to SQL Server on an EC2 instance. Each environment can have its own specific configurations, so adjusting these troubleshooting steps to fit your setup is crucial.

answered 2 years ago

  • RobBob Here: I was able to resolve the issue by dong two things:

    1. Go into SQL Server Configuration Manager => SQL Server Network Configuration => Protocols for (instance name) => TCP/IP (make sure this is "Enabled". Then double click on TCP/IP => IPALL => TCP Port and set to 1433. And click "Ok". You will need to reboot your server for it to take effect.
    2. Do not use the server/instance name in @datasrc. SET @datasrc='ec2-33-333-333-33.us-east-2.compute.amazonaws.com (NOT @datasrc='MYSERVER\APRO.ec2-33-333-333-33.us-east-2.compute.amazonaws.com)

    Success: We have a linked server!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.