AG listener Connectivity

Anashwar Nanadath 1 Reputation point
2021-11-13T17:49:30.377+00:00

Hi Team,

Multisubnet environment

Node1: Primary
Node2: DR

 I am unable to ping AG Listener from my secondary server , but able to connect the listener from SSMS 

in secondary server while pinging listener , listener is pointing to offline IP and timing out

any thoughts would be appreciated

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,692 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Dan Guzman 9,206 Reputation points
    2021-11-13T21:37:31.75+00:00

    in secondary server while pinging listener , listener is pointing to offline IP and timing out

    The PING utility only tries the first IP address returned by the listener name DNS query. This is problematic in the case of a multi-subnet AG because the first IP returned might not be the current primary node. You can use a nslookup command to see the listener IP name resolution order. Below is example output from a secondary node of a 4 node multi-subnet AG when run on the secondary 10.0.2.0/24 subnet node.

    C:\> nslookup YourAG
    Server:  YourDNS.yourdomain.com
    Address:  10.0.0.2
    
    Name:    YourAg.yourdomain.com
    Addresses:  10.0.2.4
              10.0.3.4
              10.0.4.4
              10.0.1.4
    

    As you can see, the first IP address returned was the offline IP address of the local secondary node where PING was run. PING doesn't bother to try the other listener IP addresses, including the primary node (10.0.1.4 in this example). In my experience, the local subnet IP address is returned first when PING is run on a secondary.

    A better way to test connectivity via the listener name using a SQL client tool like SQLCMD. This method will use a SQL client API which is a bit smarter than PING and try the other IP addresses, connecting to the online listener IP (primary node) even when it's not first in the list:

    SQLCMD -S YourAG -E -Q "SELECT @@SERVERNAME;"
    

  2. AmeliaGu-MSFT 13,961 Reputation points Microsoft Vendor
    2021-11-15T06:19:21.72+00:00

    Hi AnashwarNanadath-8556,

    Welcome to Microsoft Q&A.
    In addition, please refer to the following articles which might be helpful:
    Timeout occurs when you connect to a SQL Server AlwaysOn availability group listener
    Connection Timeouts in Multi-subnet Availability Group

    Best Regards,
    Amelia