Skip to content
Microsoft SQL Server

SQL Server Error 1418

The server network address cannot be reached or does not exist

Severity 16 High Availability
Applies to: SQL Server 2016 to 2025 (database mirroring endpoints), Azure SQL Managed Instance
Last technically reviewed 23 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
The server network address "TCP://SQL02.contoso.com: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.
Other forms of this message
Related error log entry when the endpoint port is taken (error 26023)
Server TCP provider failed to listen on [ 'any' <ipv4> 5022]. Tcp port is already in use.
Error number
1418
Severity
16 (user-correctable error)
State
Not documented by Microsoft (not reproduced here)
Product
Microsoft SQL Server Database Engine
Versions
SQL Server 2016 to 2025 (database mirroring endpoints), Azure SQL Managed Instance
Last reviewed
23 October 2026

What it means

Error 1418 means SQL Server could not reach the database mirroring endpoint at the TCP address you gave, so the mirroring partnership was not set up.

Database mirroring partners (and availability group replicas) talk to each other through a dedicated endpoint, by default on TCP port 5022, using addresses of the form TCP://host:port. Error 1418 is typically raised by ALTER DATABASE ... SET PARTNER when the server instance cannot establish that connection. The address in quotes is exactly what was tried: check the host name, the port and that something is listening there.

Microsoft points out that the message is broad. The endpoint may be unreachable because of the network or a firewall, but a security problem (for example the partner's service account having no CONNECT permission on the endpoint) can make the other side drop the connection silently, and that looks the same. Corrective action may be needed on both partners, even if you only ran the command on one.

Common causes

  • A firewall blocks the endpoint port on the mirror or on the principal (Microsoft notes that Windows blocks ports by default).
  • The host name or port in the TCP:// address is wrong, or the name does not resolve to the right server.
  • The database mirroring endpoint on one partner is not started, does not exist, or listens on a different port.
  • Another process or instance already holds the endpoint port (the error log then shows error 26023).
  • The service account of one partner has no login or no CONNECT permission on the other partner's endpoint, or certificate authentication does not match.
  • The mirror database is not ready: it was not restored WITH NORECOVERY from a recent full and log backup of the principal.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

Is the mirroring endpoint started, and on which port?

Run on both partners.

SELECT e.name, e.state_desc, e.role_desc, t.port, t.ip_address,
       e.connection_auth_desc, e.encryption_algorithm_desc
FROM sys.database_mirroring_endpoints AS e
JOIN sys.tcp_endpoints AS t ON t.endpoint_id = e.endpoint_id;
What to look for

One row with state_desc = STARTED on each partner, and the port matching the one in the TCP:// address. No row means there is no endpoint on that instance.

Who may connect to the endpoint?

SELECT ep.name AS endpoint_name, pr.name AS grantee, pe.permission_name, pe.state_desc
FROM sys.server_permissions AS pe
JOIN sys.endpoints AS ep ON ep.endpoint_id = pe.major_id
JOIN sys.server_principals AS pr ON pr.principal_id = pe.grantee_principal_id
WHERE pe.class_desc = N'ENDPOINT' AND ep.type = 4;

SELECT servicename, service_account
FROM sys.dm_server_services
WHERE servicename LIKE N'SQL Server (%';
What to look for

The other partner's service account (shown by the second query on that server) must be listed with CONNECT granted, unless both run under the same domain account.

What is the current mirroring state?

SELECT DB_NAME(database_id) AS database_name, mirroring_state_desc, mirroring_role_desc,
       mirroring_partner_name, mirroring_partner_instance
FROM sys.database_mirroring
WHERE mirroring_guid IS NOT NULL;
What to look for

Databases with a mirroring session and the partner address they use. Compare mirroring_partner_name with the address in the error.

Did the endpoint fail to listen?

EXEC sp_readerrorlog 0, 1, N'26023';
EXEC sp_readerrorlog 0, 1, N'endpoint';
What to look for

Error 26023 for the endpoint port means another process holds it, even if the endpoint shows STARTED. Other lines show refused or failed endpoint connections.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Test the address and port from each partner

Read-only

From the principal to the mirror and back, check that the name resolves and the port answers. A port that answers on the IP address but not on the name is a DNS problem; a port that answers nowhere is a firewall or endpoint problem.

# PowerShell on each partner
Resolve-DnsName -Name SQL02.contoso.com
Test-NetConnection -ComputerName SQL02.contoso.com -Port 5022
Get-NetTCPConnection -LocalPort 5022 -State Listen

Allow the endpoint port through the firewalls

Changes configuration

Allow inbound TCP on the endpoint port on both partners (and the witness, if any), only from the other partners. Include network firewalls and cloud security groups between them.

Start the endpoint or grant CONNECT on it

Changes permissions

If an endpoint is stopped, start it. If the partners run under different domain accounts, create a login for the partner's service account and grant it CONNECT on the endpoint only. Then rerun ALTER DATABASE ... SET PARTNER, on the mirror first and then on the principal.

Caution: Grant only CONNECT on the endpoint. The partner service account does not need sysadmin or any other server role for mirroring.

ALTER ENDPOINT Mirroring STATE = STARTED;

GRANT CONNECT ON ENDPOINT::Mirroring TO [CONTOSO\svc_sql01];

Prepare the mirror database again

Changes database state

The mirror must be restored WITH NORECOVERY from a full backup of the principal plus at least one later log backup, with no log backups missing. If in doubt, restore it again before setting the partner.

Caution: Restore onto the mirror server only, never over the principal database. RESTORE WITH REPLACE overwrites the database on the server where it runs.

Examples

Setting the partner when the mirror endpoint cannot be reached

Shown as documented by Microsoft (MSSQLSERVER_1418); not reproduced here because it needs two mirroring partners. The state is the commonly reported one. The statement runs on the principal after the mirror database was restored WITH NORECOVERY and SET PARTNER was run on the mirror.

-- On the principal SQL01
ALTER DATABASE SalesDb SET PARTNER = N'TCP://SQL02.contoso.com:5022';
Result
The server network address "TCP://SQL02.contoso.com: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.

How to prevent it

Script the endpoints, logins, CONNECT grants and firewall rules for every partner, use fully qualified names in partner addresses, and test the port in both directions before setting up the partnership. Keep the endpoint port reserved for SQL Server so no other process takes it.

Database mirroring is deprecated; for new designs, plan Always On availability groups instead, which use the same kind of endpoint and need the same network preparation.

Common questions

The endpoint shows STARTED. Why can it not be reached?

STARTED only means SQL Server wants to listen. A firewall can still block the port, another process can hold it (error 26023 in the log), or the name in the address can resolve to a different machine. Test the port from the other partner.

Which server do I fix, the principal or the mirror?

Possibly both. Microsoft notes that even when SET PARTNER fails on the principal, corrective action may be needed on both partners, for example a firewall on each side.

Is port 5022 required?

No. 5022 is only the usual default. Any free port works as long as the endpoint listens on it, the firewall allows it, and the partner address uses the same port.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.