ERROR:
Error: Microsoft ODBC Driver 11 for SQL Server : Unable to access the ‘database_name’ database because no online secondary replicas are enabled for read-only access. Check the availability group configuration to verify that at least one secondary replica is configured for read-only access. Wait for an enabled replica to come online, and retry your read-only operation.
EXPLANATION:
This error may occur when you trying to connect to a ReadIntent Only Readable Secondary server through an AlwaysOn Availability Group Listener.
SOLUTION:
If this error has occured, make sure that the SQL Server service of the Readable Secondary server that you set as ReadIntent Only in the AlwaysOn Availability Group is running, that the ports are open, and that this server is accessible. If you do not have a server that you set as ReadIntent Only in your AlwaysOn Availability Group, then make sure that there is no parameter like “ApplicationIntent = ReadOnly” in the Connection String of the application that this user is using. If this application is SQLCMD, this parameter will be “-K ReadOnly”.