Hi @Jiong AN ,
> When u trying to connect through the listener name, you only allowed by the specifed port number right?
Yes, you are right. I also mentioned this in my first reply.
I did a test to help you understood your issue.
Server A AG primary replica Instance number port number 1433
Server B AG secondary replica instance number port number 36888
AG listener DNS name---AGlistenertest AG listener port number 12345
- Server A is primary replica, server B is secondary replica.
1)Using AGlistenertest,12345, the connection is successful.
2)Using AGlistenertest,1433, the connection is successful. - Failover the AG primary replica from server A to server B. Then the new primary replica is server B.
1)Using AGlistenertest,12345, the connection is successful.
2)Using AGlistenertest,1433, the connection failed.
3)Using AGlistenertest,36888, the connection is successful.
When you successfully connected, it happened that the port number of the primary replica SQL instance port is 1433. We can use the primary replica instance port number to connect, but if AG failover, you need to change the port number in the connection string to the port number of new primary replica port number, but if you use AG listener port number, no matter which replica is primary replica and how the port number of the instance is changed , it will not affect the connection of you AG.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.