Configuring SQL mirroring

During configuring database mirroring via Microsoft SQL Management Studio you can stumble upon error message:

The server network address "TCP://srv-sql.test.local:5022" can not be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational. (Microsoft SQL Server, Error: 1418)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.5548&EvtSrc=MSSQLServer&EvtID=1418&LinkId=20476

After checking that both servers have network access, mirroring endpoints were actually created and there are no firewall restrictions it turned out that you must explicitly give permissions for connecting to that newly created endpoint (Why SQL Management Studio couldn't do it during endpoint creation or at least warn?).
Worth familiarizing: Example: Setting Up Database Mirroring Using Windows Authentication (Transact-SQL)
Here is SQL snippet:

-- get mirroring endpoint
select name
from sys.database_mirroring_endpoints

-- sql server runs as network service
CREATE LOGIN [test\srv-sql$] FROM WINDOWS;
GRANT CONNECT ON ENDPOINT::<mirroring endpoint name> TO [test\srv-sql$];

-- sql server run as service account
CREATE LOGIN [test\svc-sql] FROM WINDOWS;
GRANT CONNECT ON ENDPOINT::<mirroring endpoint name> TO [test\svc-sql];
Show Comments