Identify SQL Server TCP IP port being used
How do I find out what TCP/IP port SQL Server is using for a specific SQL Server instance? In this tip we look at different ways a database administrator can identify the port used by instance of SQL Server.
You probably know that by default, the SQL Server Database Engine listens on port 1433 for TCP/IP connections and port 1434 is used for UDP connections. However, if you have more than one instance of SQL Server running on the same server or if you have changed the default port then it may be difficult to know the port used by the database engine.
In this tip we will take a look at three different ways you can identify the port used by an instance of SQL Server.
- Reading SQL Server Error Logs
- Using SQL Server Configuration Manager
- Using Windows Application Event Viewer
Let's take a look at each of the above options in detail.
1 - Identify Port used by Named Instance of SQL Server Database Engine by Reading SQL Server Error Logs
The SQL Server Error Log is a great place to find information about what is happening on your database server. The SQL Server Error Log records information with respect to the port in which an instance of the SQL Server Database Engine is listening. You can execute the below TSQL command which uses the XP_READERRORLOG extended stored procedure to read the SQL Server Error Log to find the port the SQL Server Database Engine is listening.
USE master GO xp_readerrorlog 0, 1, N'Server is listening on', N'any', NULL, NULL, N'asc' GO
The parameters you can use with XP_READERRRORLOG are mentioned below for your reference:
- Value of error log file you want to read: 0 = current, 1 = Archive #1, 2 = Archive #2, etc...
- Log file type: 1 or NULL = error log, 2 = SQL Agent log
- Search string 1: String one you want to search for
- Search string 2: String two you want to search for to further refine the results
- Search from start time
- Search to end time
- Sort order for results: N'asc' = ascending, N'desc' = descending
By default, there are six archived SQL Server Error Logs along with the ERRORLOG which is currently used. However, it is a Best Practice to increase the number of SQL Server Error Logs from the default value of six. Hence I recommend that you read this tip Increase the Number of SQL Server Error Logs.
If you use sp_cycle_errorlog to cycle the SQL Server Error Logs you will need to look in the archive files to find the port information, because this is only stored in the startup error log.
Also, if you are using endpoints, such as Database Mirroring these will show up as ports as well. The way to differentiate the ports being used is to look at the data where the ProcessInfo column equals 'Server' to find the port used for the database engine.
2 - Identify Port used by SQL Server Database Engine Using SQL Server Configuration Manager
1. Open SQL Server Configuration Manager
2. In SQL Server Configuration Manager, expand SQL Server Network Configuration and then select Protocols for <instance name> on the left panel. To identify the TCP/IP Port used by the SQL Server Instance, right click on TCP/IP and select Properties from the drop down as shown below.
3. In TCP/IP Properties window click on the IP Addresses tab and you will see the Port used by the instance of SQL Server in either TCP Dynamic Ports for a dynamic port or TCP Port for a static port as highlighted in the snippet below.
3 - Identify Port used by SQL Server Database Engine Using Application Event Viewer
1. Open Event Viewer, Computer Management or Server Manager (to find Event Viewer)
2. Under Event Viewer, expand Windows Logs and then select Application on the left side panel. In the right panel you need to filter for events with Event ID 26022 as shown in the below snippet. To set a filter right click on Application and select Filter Current Log.
3. To view the Port Number double click an event and you can see the event properties as shown below. In this case, the named instance of SQL Server is listening on Port 57319. Note: you should look for the following Event "Server is listening on [ 'any' <ipv4> PortNumber]" in the event viewer. Also, if you have endpoints setup like Database Mirroring these will show up under EventID 26022 as well, so it gets a little harder to tell using this method.
- Keep this tip handy to find out what port is being used by SQL Server
- Refer to these other related tips:
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2022-02-24