You are currently offline, waiting for your internet to reconnect

How to configure SQL Server to listen on a specific port

Extended support for SQL Server 2005 ends on April 12, 2016

If you are still running SQL Server 2005 after April 12, 2016, you will no longer receive security updates and technical support. We recommend upgrading to SQL Server 2014 and Azure SQL Database to achieve breakthrough performance, maintain security and compliance, and optimize your data platform infrastructure. Learn more about the options for upgrading from SQL Server 2005 to a supported version here.

Summary
This article describes static and dynamic port allocation in Microsoft SQL Server 2008, SQL Server 2005, or SQL Server 2000 . It also discusses how to configure an instance of SQL Server to use either a static port or a dynamic port.
More information
Static port allocation
If you configure an instance of SQL Server to use a static port, and you restart the instance of SQL Server, the instance of SQL Server listens only on the specified static port. The SQL Server clients must send all the requests only to the static port on which the instance of SQL Server is listening.

However, if an instance of SQL Server is configured to listen on a static port, and another program that is running on the computer is already using the specified static port when SQL Server is started, SQL Server does not listen on the specified static port.

By default, the default instance of SQL Server listens for requests from SQL Server clients on static port 1433. Therefore, the client network libraries assume that either port 1433 or the global default port that is defined for that client computer is used to connect to the default instance of SQL Server.

If a default instance of SQL Server is listening on a port other than port 1433, you must either define a server alias name or change the global default port by using the Client Network Utility. However, you can also make the default instance of SQL Server listen on multiple static ports.

For more information about how to set up SQL Server to listen on multiple static TCP ports, click the following article number to view the article in the Microsoft Knowledge Base:
294453 How to set up SQL Server to listen on multiple static TCP ports
The default instance of SQL Server does not support dynamic port allocation. However, the named instances of SQL Server support allocation of both static and dynamic ports. By default, a named instance of SQL Server listens on a dynamic port. For a named instance of SQL Server, the SQL Server Browser service for SQL Server 2008, SQL Server 2005, or the SQL Server Resolution Protocol (SSRP) for SQL Server 2000 is always used to translate the instance name to a port, regardless of whether the port is static or dynamic. The Browser service or SSRP is never used for a default instance of SQL Server.

Dynamic port allocation
Only named instances of SQL Server can use the dynamic port allocation process. In the dynamic port allocation process, when you start the instance of SQL Server for the first time, the port is set to zero (0). Therefore, SQL Server requests a free port number from the operating system. As soon as a port number is allocated to SQL Server, SQL Server starts listening on the allocated port.

The allocated port number is written to the Windows registry. Every time that you start that named instance of SQL Server, it uses that allocated port number. However, in the unlikely case that another program that is already running on the computer is using that previously allocated (but not static) port number when you start SQL Server, SQL Server selects another port.

When you start the named instances of SQL Server the second time, SQL Server opens the listening port number that was started the first time, as follows:
  • If the port is opened without errors, SQL Server listens on the port.
  • If the port is not opened, and errors occur, SQL Server behaves as follows:
    • You receive the following error message:
      Error ID 10048 (WSAEADDRINUSE)
      When you receive this error message, SQL Server determines that the port is being used. Then, the port number is set to zero (0) again. Therefore, an available port is assigned. And, SQL Server waits for the client connection request on the port.
    • If you receive an error message that does not mention error 10048, SQL Server 2000 determines that it is impossible to wait for the connection request on the port. Therefore, the port is not opened.
Notes
  • In SQL Server 2005, when you receive the following error message, the port number is set to zero (0) and is opened.
    Error ID 10013 (WSAEACCES)
  • In Windows Server 2003 or in Windows XP, you may receive the 10013 error message instead of the 10048 error message when the port that is trying to open is used exclusively.
When an instance of SQL Server uses dynamic port allocation, the connection string that is built at the SQL Server client does not specify the destination TCP/IP port unless the user or the programmer explicitly specifies the port. Therefore, the SQL Server client library queries the server on UDP port 1434 to collect the information about the destination instance of SQL Server. When SQL Server returns the information, the SQL Server client library sends the data to the appropriate instance of SQL Server.

If UDP port 1434 is disabled, the SQL Server client cannot dynamically determine the port of the named instance of SQL Server. Therefore, the SQL Server client may be unable to connect to the named instance of SQL Server. In this situation, the SQL Server client must specify the dynamically allocated port where the named instance of SQL Server 2008, SQL Server 2005, or SQL Server 2000 is listening.

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
265808How to connect to SQL Server by using an earlier version of SQL Server


Verifying the port configuration of an instance of SQL Server
Note Default instances of SQL Server always use a static port.

First verify that your instance of SQL Server has the TCP/IP protocol enabled. Then examine the SQL Server error log to find which TCP/IP port your instance of SQL Server is "listening on". Additionally, in SQL Server 2005 and in later versions, you can check settings in the SQL Server Configuration Manager. If you want to see the SQL error log from inside a program, follow these steps.

Note For SQL Server 2000, use Query analyzer to execute the following queries.
  1. Start SQL Server Management Studio, and then connect to the instance of SQL Server.
  2. Run the following query:
    Use master Go Xp_readerrorlog
  3. In the Results pane, locate the following text (where X.X.X.X is the IP address of the instance of SQL Server and Y is the TCP/IP port where SQL Server is listening):
    SQL server listening on X.X.X.X: Y
    Note: For example, if you locate the "SQL server listening on 10.150.158.246: 1433" text in the Results pane, 10.150.158.246 is the IP address of the SQL Server and 1433 is the TCP/IP port where the instance of SQL Server is listening.
To verify the port configuration of an instance of SQL Server, follow these steps:
  1. Start Registry Editor.
  2. In Registry Editor, locate the following registry key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<InstanceName>\MSSQLServer\SuperSocketNetLib\Tcp
    Note If you are using SQL Server 2005, locate the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<MSSQL.x>\MSSQLServer\SuperSocketNetLib\Tcp\IPAll
    Note the TCPDynamicPorts value and the TCPPort value. These values appear as follows, depending on your port allocation method: 
    • Static Port Allocation
      If you configure an instance of SQL Server to use a static port, and you have not yet restarted the instance of SQL Server, the registry values are set as follows:
      TCPDynamicPorts = Last port that is used
      TCPPort = New static port to be used after the next restart; new static port that you set by using the Server Network Utility
      However, if you configure an instance of SQL Server to use a static port, and you restart the instance of SQL Server, the registry values are set as follows:
      TCPDynamicPorts = Blank
      TCPPort = New static port that you set by using the Server Network Utility
    • Dynamic Port Allocation
      If you configure an instance of SQL Server to use dynamic port allocation, and you have not yet restarted the instance of SQL Server, the registry values are set as follows:
      TCPDynamicPorts = Blank
      TCPPort = 0
      However, if you configure an instance of SQL Server to use dynamic port allocation, and you restart the instance of SQL Server, the registry values are set as follows:
      TCPDynamicPorts = Current port that is used
      TCPPort = Current port that is used


Configuring an instance of SQL Server to use a static port

SQL Server 2008 and SQL Server 2005

To configure an instance of SQL Server 2008 or SQL Server 2005 to use a static port, follow the steps that are described in the How to: Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager) topic in SQL Server 2005 Books Online or in SQL Server 2008 Books Online.

To configure a static port for the specialized Dedicated Administrator Connection (DAC), you must update the registry key that corresponds to your instance. For example, the registry key may be the following:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.X\MSSQLServer\SuperSocketNetLib\AdminConnection\Tcp
Note The "X" in "MSSQL.X" is a number that indicates the directory where the instance is installed for SQL Server 2005 or the instance name for SQL Server 2008.

SQL Server 2000

To configure an instance of SQL Server to use a static port, follow these steps:
  1. Start the Server Network Utility. To do this, do one of the following:
    • Click Start, point to Programs, point to Microsoft SQL Server, and then click Server Network Utility.
    • Click Start, and then click Run. In the Open box, type svrnetcn.exe, and then click OK.
    The Server Network Utility dialog box appears.
  2. In the Server Network Utility dialog box, click the General tab.
  3. In the Instance(s) on this server list, select your instance of SQL Server.

    Note If TCP/IP protocol is disabled, enable it now. To do this, click TCP/IP in the Disabled Protocols list, and then click Enable.
  4. In the Enabled Protocols list, click TCP/IP, and then click Properties.
  5. In the Default port box, type a static port number, and then click OK.

    Note The static port that you specify must differ from the dynamic port that your instance of SQL Server is currently listening on. For example, if an instance of SQL Server is currently listening on dynamic TCP/IP port 1400, type 1500 for the new static port.
  6. Click OK twice.
  7. Restart the instance of SQL Server.
  8. View the SQL Server error logs to verify that the instance of SQL Server is using the static port.

    Note If you have a clustered instance of SQL Server, and you follow the specified steps on a cluster node, you may notice that the TCPDynamicPorts registry values and the TCPPort registry values on other cluster nodes still hold the old values. When you move the SQL Server group to the corresponding cluster node, and then bring SQL Server online on the cluster node, the registry values on the cluster nodes will reflect the correct values.
You may want to set the static port of your instance of SQL Server to the same port number as the dynamic port that it used earlier. To do this, follow these steps:
  1. View the TCPDynamicPorts registry value and the TCPPort registry value to determine the dynamic port number that the earlier instance of SQL Server used.
  2. In the Server Network Utility, set the static port to a different port number than the registry value that you determined in step 1.
  3. Restart the instance of SQL Server.
  4. In the Server Network Utility, set the static port to the registry value that you determined in step 1.
  5. Restart the instance of SQL Server.


Configuring an instance of SQL Server to use a dynamic port

SQL Server 2008 and SQL Server 2005

To configure your instance of SQL Server 2008 or your instance of SQL Server 2005 to use a dynamic port, use the similar method described in the "How to: Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager)" topic in SQL Server 2008 Books Online or in SQL Server 2005 Books Online. For more information, see the Server Network Configuration topic in SQL Server 2008 Books Online or in SQL Server 2005 Books Online.

SQL Server 2000

To configure your instance of SQL Server to use a dynamic port, follow these steps:
  1. Start the Server Network Utility. To do this, do one of the following:
    • Click Start, point to Programs, point to Microsoft SQL Server, and then click Server Network Utility.
    • Click Start, and then click Run. In the Open box, type svrnetcn.exe, and then click OK.
    The Server Network Utility dialog box appears.
  2. In the Server Network Utility dialog box, click the General tab.
  3. In the Instance(s) on this server list, select your instance of SQL Server.

    Note If TCP/IP protocol is disabled, enable it now. To do this, click TCP/IP in the Disabled Protocols list, and then click Enable.
  4. In the Enabled Protocols list, click TCP/IP, and then click Properties.
  5. In the Default port box, type 0, and then click OK.
  6. Click OK, and then click OK again.
  7. Restart the instance of SQL Server.
  8. View the SQL Server error logs to verify that the instance of SQL Server is using the dynamic port.

    Note If you have a clustered instance of SQL Server, and you follow the specified steps on a cluster node, you may notice that the TCPDynamicPorts registry values and the TCPPort registry values on other cluster nodes still hold the old values. When you move the SQL Server group to the corresponding cluster node, and then bring SQL Server online on the cluster node, the registry values on the cluster nodes will reflect the correct values.


Troubleshooting
If the SQL Server clients cannot access an instance of SQL Server after you have configured it to use a static TCP/IP port, the following causes may exist:
  • A firewall may be blocking the specified TCP/IP port.
    If the port that the instance of SQL Server is currently listening on is blocked by your firewall, the connections will fail. For information about how to configure your firewall to work with your SQL Server, please see the Configuring the Windows Firewall to Allow SQL Server Access topic in SQL Server 2008 Books Online. Although this topic is specific to SQL Server 2008, most of the information applies to SQL Server 2005 and SQL Server 2000.

    For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
    287932 TCP/IP port numbers required to communicate to SQL over a firewall
    318432 BUG: Cannot connect to a clustered named instance through a firewall
    968872 How to open the firewall port for SQL Server on Windows Server 2008
  • Another program may already be using the specified TCP/IP port.
    If another program is already using the specified TCP/IP port, the port is not available to the instance of SQL Server and SQL Server clients may be unable to connect to the instance of SQL Server.

    This problem is specific to an instance of SQL Server that is configured to use a static TCP/IP port. This problem does not occur for an instance of SQL Server that is configured to use dynamic port allocation. In dynamic port allocation, if another program is already using the specified TCP/IP port when you start the instance of SQL Server, the instance of SQL Server selects a new port.

    For more information, click the following article number to view the article in the Microsoft Knowledge Base:
    293107 Clients cannot communicate to SQL Server through port 1433 or the port SQL Server is listening on
  • A Named Instance of SQL Server is listening on port 1433.
    If a Named Instance of SQL Server is listening on port 1433, the Microsoft OLE DB Provider for SQL Server (Provider=SQLOLEDB) and the SQL Server ODBC Driver (Driver={SQL Server}) may be unable to connect to the server. This failure to connect occurs when both the instance name and the port number from the connection string are omitted. If no port number is specified, the drivers validate the server instance name. If the server instance name is not the default instance, MSSQLSERVER, the connection is unsuccessful. To enable a successful connection, you must specify the instance name or the port number in the connection string or in a SQL Alias. 

    Notes
    • We do not recommend that you have a named instance listen on port 1433.
    • Other Providers, such as System.Data.SqlClient and SQL Native Client (Provider=SQLNCLI), do not perform the instance name check and connect successfully.
References
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
286303 Behavior of SQL Server 2000 network library during dynamic port detection
273673 Description of SQL Virtual Server client connections
328383 SQL Server clients may change protocols when the client computers try to connect to an instance of SQL Server
For more information about how to configure SQL Server to listen on different ports on different IP addresses, see the How to configure SQL server to listen on different ports on different IP addresses? topic on the following Microsoft SQL Server Support Blog website:
Properties

Article ID: 823938 - Last Review: 07/12/2013 07:51:00 - Revision: 11.1

Microsoft SQL Server 2008 Developer, Microsoft SQL Server 2008 Enterprise, Microsoft SQL Server 2008 Standard, Microsoft SQL Server 2008 Express, Microsoft SQL Server 2008 Workgroup, Microsoft SQL Server 2005 Developer Edition, Microsoft SQL Server 2005 Enterprise Edition, Microsoft SQL Server 2005 Standard Edition, Microsoft SQL Server 2005 Express Edition, Microsoft SQL Server 2005 Workgroup Edition, Microsoft SQL Server 2000 Developer Edition, Microsoft SQL Server 2000 Enterprise Edition, Microsoft SQL Server 2000 Standard Edition, Microsoft SQL Server 2008 R2 Developer, Microsoft SQL Server 2008 R2 Enterprise, Microsoft SQL Server 2008 R2 Express, Microsoft SQL Server 2008 R2 Standard, Microsoft SQL Server 2008 R2 Workgroup

  • kbsqlsetup kbsql2005cluster kbconnectivity kbupdate kbsqlclient kbnetwork kbfirewall kbconfig kbregistry kbhowtomaster KB823938
Feedback
var varClickTracking = 1; var varCustomerTracking = 1; var Route = "76500"; var Ctrl = ""; document.write(" gRepeat: language in languagesListForLargeScreens track by $index -->
United States (English)
香港特別行政區 - 繁體中文
El Salvador - Español
Panamá - Español
Uruguay - Español
대한민국 - 한국어
España - Español
Paraguay - Español
Venezuela - Español
amp;did=1&t="> var varCustomerTracking = 1; var Route = "76500"; var Ctrl = ""; document.write(" ')[0].appendChild(m);" onload="var m=document.createElement('meta');m.name='ms.dqp0';m.content='false';document.getElementsByTagName('head')[0].appendChild(m);" src="http://c1.microsoft.com/c.gif?"> >>