Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1436: Service Broker ID Fix

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server error 1436 means the Service Broker conversation is trying to reach a remote broker ID that the local instance does not recognize. The fix is to stop the failed conversation, confirm the service and contract on both sides, and re-create the route or dialog so the broker IDs match. You cannot repair a mismatched remote broker ID in place; you must end the broken conversation and start a new one. This guide walks through the safe, supported steps.

What You'll Need

  • SQL Server Management Studio (SSMS) or another client that can run T-SQL.
  • Permissions to run ALTER DATABASE, END CONVERSATION, and to create routes and services.
  • The names of the databases, services, contracts, and routes involved on both the initiating and target instances.
  • Network connectivity between the instances if they are on different servers (Service Broker uses TCP).
  • A maintenance window: ending conversations can discard queued messages.

Step-by-Step

  1. Identify the failed conversation. Query the transmission queue and the conversation endpoints. Run:
    SELECT conversation_handle, service_contract_name, state_desc, far_service, far_broker_instance FROM sys.conversation_endpoints WHERE state_desc IN ('ERROR','DISCONNECTED_OUTBOUND','DISCONNECTED_INBOUND');
    Note the conversation_handle and the far_broker_instance value. Error 1436 typically appears when the far_broker_instance does not match the broker ID advertised by the remote service.
  2. Confirm the remote broker ID. On the target instance, run:
    SELECT service_broker_guid FROM sys.databases WHERE name = 'YourDatabase';
    Compare this GUID with the far_broker_instance in the failed conversation. If they differ, the route is pointing to an old or wrong broker ID, often after a database restore or failover.
  3. Check the route on the initiating instance. Run:
    SELECT name, remote_service_name, broker_instance, address FROM sys.routes;
    The broker_instance column must match the remote database's service_broker_guid. If it is NULL or different, the route is stale.
  4. End the broken conversation. Run:
    END CONVERSATION 'conversation_handle' WITH CLEANUP;
    Use WITH CLEANUP only when the conversation cannot be ended normally; it removes all messages for that conversation. Repeat for each failed handle. This step discards any undelivered messages, so export or process them first if they matter.
  5. Re-create or correct the route. If the route has the wrong broker ID, drop and recreate it:
    DROP ROUTE RouteName;
    CREATE ROUTE RouteName WITH SERVICE_NAME = 'target_service', ADDRESS = 'TCP://targetserver:4022', BROKER_INSTANCE = 'correct-guid';
    Replace the GUID with the value from step 2. If the route uses a DNS name, verify it resolves correctly from the initiating server.
  6. Verify the service and contract on both sides. On each instance run:
    SELECT name FROM sys.services;
    SELECT name FROM sys.service_contracts;
    The initiating service, target service, and contract names must match exactly, including case where the database collation is case-sensitive.
  7. Start a new conversation. From the initiating database, run:
    DECLARE @h UNIQUEIDENTIFIER; BEGIN DIALOG @h FROM SERVICE InitiatorService TO SERVICE 'TargetService' ON CONTRACT ContractName WITH ENCRYPTION = OFF; SELECT @h;
    Then send a test message and confirm it arrives in the target queue. If the new dialog fails with 1436 again, the route or broker ID is still wrong; return to step 2.
  8. Check the error log and queue state. Run:
    SELECT * FROM sys.transmission_queue;
    and review the SQL Server error log for transmission errors. A transmission_status of 'Connection refused' or 'The broker ID is not valid' points to a route or firewall problem, not the dialog itself.

Common Mistakes

  • Ending the conversation with WITH CLEANUP before checking whether messages are still needed. This permanently discards them.
  • Recreating the route without updating BROKER_INSTANCE after a database restore, so the old GUID persists.
  • Assuming the broker ID is the same as the database name or server name. It is a GUID stored in sys.databases.
  • Forgetting that Service Broker endpoints must be started and that the port (often 4022) must be open on both sides.
  • Mismatched contract or service names due to case sensitivity or extra spaces.
  • Running END CONVERSATION from the wrong database context. Always USE the database that owns the conversation.

Tips

  • Record the service_broker_guid for every database before and after a restore or failover; this is the most common source of 1436.
  • Use WITH ENCRYPTION = OFF only for testing; in production, configure certificates correctly rather than disabling encryption permanently.
  • Keep a script that recreates routes with the correct broker ID so recovery is quick.
  • Monitor sys.transmission_queue regularly; a growing queue is an early warning of route or connectivity problems.
  • If the database was restored from another server, consider whether the broker ID should be regenerated; changing it requires updating every remote route that points to it.

Troubleshooting

If error 1436 persists after recreating the route, verify the remote endpoint is listening: run SELECT * FROM sys.service_broker_endpoints; and confirm state_desc is STARTED. Check that the firewall allows the Service Broker port on both servers. If the route uses a hostname, test resolution with ping or nslookup from the SQL Server host. If the broker ID still does not match, confirm you are querying the correct database on the remote instance; a common mistake is reading the GUID from master instead of the application database. If conversations fail immediately after a failover, the broker ID may have changed; update all routes that reference it. When messages are stuck in the transmission queue with a status mentioning the broker ID, the route's BROKER_INSTANCE is the first thing to check. Finally, if you cannot end a conversation because it is in a state that blocks cleanup, restart the SQL Server service during a maintenance window, then retry END CONVERSATION WITH CLEANUP.

Frequently Asked Questions

What causes SQL Server error 1436?

It occurs when the broker ID in a route or dialog does not match the service_broker_guid of the remote database, usually after a restore, failover, or route misconfiguration.

Can I fix error 1436 without ending the conversation?

No. The dialog is bound to the old broker ID. You must end the failed conversation and start a new one after correcting the route.

Does END CONVERSATION WITH CLEANUP delete messages?

Yes. WITH CLEANUP removes all messages associated with that conversation, including undelivered ones. Process or export them first if needed.

Where do I find the correct broker ID?

Run SELECT service_broker_guid FROM sys.databases WHERE name = 'YourDatabase'; on the target instance.

Why does the error return after a database restore?

A restore can assign a new service_broker_guid. Routes on other instances still point to the old GUID until you update them.

Is error 1436 related to encryption?

Not directly, but encryption or certificate problems can prevent the dialog from starting and surface alongside broker ID errors. Verify certificates separately.