Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlAGReplica: Failed to connect to SQL instance 'hostname\MSSQLSERVER' #1442

Closed
emyatsuna opened this issue Nov 8, 2019 · 4 comments
Closed
Labels
question The issue is a question.

Comments

@emyatsuna
Copy link

emyatsuna commented Nov 8, 2019

Hi,

I was able to create an AG group and listener in the Primary node and tried to connect the details in secondary using SqlAGReplica. I got the following error.

Error: PowerShell DSC resource MSFT_SqlAGReplica failed to execute Set-TargetResource functionality with error message: System.InvalidOperationException: Failed to connect to SQL instance 'hostname\MSSQLSERVER'.

Here are my parameters passed in:

 sqlagreplica{'SQLAddReplica':
      ensure = 'Present'
      name = 'hostname\MSSQLSERVER'
      availabilitygroupname = 'AGGroup'
      servername = 'hostname'
      instancename = 'MSSQLSERVER'
      primaryreplicaservername = $primaryhost
      primaryreplicainstancename = 'MSSQLSERVER'
      endpointhostname = 'hostname'
      failovermode = 'Automatic'
      availabilitymode =  'SynchronousCommit'
      psdscrunascredential = $SqlAdministratorCredential
  }

Any idea what could be the best way to do? I keep on bumping Error 26 when manually connecting using 'hostname\MSSQLSERVER' but successfully connected using 'AGGroup\MSSQLSERVER'.

Thanks.

@emyatsuna emyatsuna changed the title SqlAGReplica: Failed to connect to SQL instance 'myhost\MSSQLSERVER' SqlAGReplica: Failed to connect to SQL instance 'hostname\MSSQLSERVER' Nov 8, 2019
@johlju johlju added the question The issue is a question. label Nov 9, 2019
@johlju
Copy link
Member

johlju commented Nov 9, 2019

This one might have been answered before, or something similar to it, but not sure. 🤔 Have you check other issues around SqlAG and SqlAGReplica for similar problems?

@emyatsuna
Copy link
Author

Hi @johlju, thanks for the reply.

Yes, I was able to Create AG using the SqlAG on the Primary node. However, I'm unable to add replica using the SqlAGReplica in the Secondary node. I used the same credentials on both Primary and Secondary nodes. I followed the steps from #910 and using the default port 5022 for SQLServerEndpoint. I can relate this to the #1220 issue. I am still getting failed to connect to instance error remotely. Appreciate if you can provide me a link to the answered issues? Thanks.

@emyatsuna
Copy link
Author

Hi, just an update. I found the solution with this one. Turns out this is Firewall problem between my Primary and Secondary nodes. Thanks.

Resolved using the following link: https://www.sqlserverlogexplorer.com/fix-error-code-26/#

@johlju
Copy link
Member

johlju commented Nov 12, 2019

Thank you for the update @emyatsuna, this will help other users too.

@johlju johlju closed this as completed Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue is a question.
Projects
None yet
Development

No branches or pull requests

2 participants