When replicating from MS SQL Always On Availability Group endpoint and facing a problem of Replicate unable to establish connection to replicas with the following error:
Failed to connect to replica 'XXXXXXXX\YYYYYY'
RetCode: SQL_ERROR SqlState: 08001 NativeError: 2 Message: [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [2]
[SOURCE_CAPTURE ]T: sqlserver_src_set_odbc_connection_string(): connection string (without credentials): 'DRIVER={ODBC Driver 17 for SQL Server};SERVER=XXXXXXXX.ZZZZ.net;DATABASE=dbname;Trusted_Connection=no;' (sqlserver_endpoint_util.c:222)
Resolution
Problem is caused by wrong alias setting on the AlwaysOn Availability Group
The name of the alias needs to be XXXXXXXX.ZZZZ.net for connecting to replica XXXXXXXX\YYYYYY.