How to fix Error 4135 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 4135 — Synonyms on Queues Not Allowed

Why This Error Happens

This error occurs because SQL Server’s Service Broker architecture explicitly prohibits the creation of synonyms that reference queue objects. Queues are specialized internal structures used strictly for message storage and retrieval within Service Broker conversations, and they do not support the abstraction layer that synonyms provide. When a developer or migration script attempts to create a synonym pointing to a queue object (rather than a table, view, or procedure), SQL Server 2025 rejects the DDL operation to maintain the integrity of the messaging subsystem.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Synonym and Queue

  • Run a query against sys.synonyms to locate the synonym referenced in the error message.
  • Use the following script to cross-reference the base object type:
SELECT name, base_object_name 
FROM sys.synonyms 
WHERE name = 'YourSynonymName';
  • Confirm that the base_object_name points to a Service Broker queue by checking sys.service_queues.

Step 2: Drop the Invalid Synonym

  • Since synonyms cannot legally wrap queue objects, the only immediate fix is removal.
  • Execute the drop command in SQL Server Management Studio (SSMS) or via sqlcmd on Windows Server 2025:
DROP SYNONYM dbo.YourSynonymName;
  • Verify there are no dependent stored procedures or views still referencing this synonym before deletion.

Step 3: Redirect Application Logic to the Queue Directly

  • Update your application code or stored procedures to reference the queue object directly using SEND and RECEIVE statements rather than relying on synonym abstraction.
  • Example direct reference syntax:
RECEIVE TOP(1) * FROM dbo.YourActualQueueName;
  • Ensure connection strings and ORM mappings (e.g., Entity Framework) are updated to bypass the synonym layer for this specific object.

Step 4: Re-deploy and Validate Schema Scripts

  • If this error surfaced during a database migration or DACPAC deployment on Windows Server 2025, check your source control schema files for legacy synonym creation scripts targeting queues.
  • Remove these specific CREATE SYNONYM statements from your build pipeline (e.g., Azure DevOps or GitHub Actions YAML) to prevent recurrence in future deployments.

Alternative or Verification Steps

  • Verification: Run SELECT * FROM sys.synonyms WHERE base_object_name LIKE '%YourQueueName%'; to confirm zero results are returned, verifying the orphaned synonym has been successfully purged.
  • Alternative: If the application architecture requires an abstraction layer for security reasons, create a stored procedure wrapper that internally executes the RECEIVE statement, and grant EXECUTE permissions on that procedure instead of attempting to synonym-wrap the queue.