Overview of SQL Server Ports (2024)

Overview of SQL Server Ports (1)

Overview of SQL Server Ports (2)June 17, 2019 by Rajendra Gupta

This article is useful for a beginner in SQL Server administration and gives insights about the SQL Server Ports, the methods to identify currently configured ports.

Introduction

We can define the port as an endpoint of service for communication purposes. It might bind to a particular application or service. Once we install SQL Server, it configures default ports for SQL Server services. Each client application uses the combination of IP addresses and port number to connect to SQL Server.

We can have two kinds of SQL Server Ports in SQL Server.

  1. Static Port: A static port is always bound to a service or application. It does not change due to a service or system restart. By default, SQL Server uses static TCP port number 1433 for the default instance MSSQLSERVER. If you configure SQL Server to use a static port other than the default port, you should communicate it to the clients or application owners to specify in the connection string
  2. Dynamic Port: You can configure SQL Server to use a dynamic port. If you use dynamic port allocation, you specify port number zero in the network configuration. Once SQL Service restarts, it requests a free port number from the operating system and assigns that port to SQL Server.

    As you know, Application uses a combination of SQL Server IP address and port number, you might think of a question – How will an application know the port number for connecting to SQL Server?

Once the operating system allocates a dynamic SQL Server Port to SQL Server, it writes that port number in the Windows registry. SQL Server Browser service uses UDP static port 1434. It reads the registry for the assigned TCP port. SQL Server client library connects and sends a UDP message using port 1434. SQL Server Browser service gives back the port number of a specific instance. An application can connect to SQL Server using that dynamic SQL Server port. SQL Server default instance uses the static port; therefore, SQL Server Browser does not return port for the default instance.

In most of the cases, SQL Server uses the same dynamic the SQL Server Port upon restart of the SQL Service as well. Suppose you stopped SQL Services and operating system allocated the dynamic port number (previously assigned to SQL) to another service, SQL Server gets another dynamic port assigned to it.

SQL Browser service is essential for the named instances with dynamic port allocation. It should be in running status for application to query and get the port details.

Check SQL Server Port Number

In this section, we will check a different method to check for the SQL Server Port number.

Method 1: SQL Server Configuration Manager:

It is the most common method to find the SQL Server Port number.

  • Step 1:

    Open SQL Server Configuration Manager from the start menu. In case you have multiple SQL Server versions you might get an error message while opening SQL Server Configuration Manager:

    Cannot connect to WMI provider. You do not have permission or the server is unreachable

    In order to fix it, open the administrative command prompt and execute the following command

    1

    > mofcomp "%programfiles(x86)%\Microsoft SQL Server\150\Shared\sqlmgmproviderxpsp2up.mof"

    In this command, change the SQL Server version

    • SQL 2008 – 100
    • SQL 2012 – 110
    • SQL 2014 – 120
    • SQL2016 – 130
    • SQL 2017 – 140
    • SQL 2019 – 150

  • Step 2:

    Go to Network Configuration, click the SQL instance for which you want to check SQL port

  • Step 3:

    It opens the protocols list. Right click on TCP/IP and properties

    Overview of SQL Server Ports (4)

  • Step 4: Click on IP Addresses and scroll down to IPAll group. You can see TCP dynamic SQL ports and TCP port in the following screenshot.

    Overview of SQL Server Ports (5)

    TCP dynamic ports value shows that we are using dynamic ports configuration. The Current assigned TCP dynamic SQL port is 51688.

    If we want to use a static port, remove the dynamic port value and specify a static port in the TCP port. This port number should be unique and not being used by other applications. You need to restart SQL Services to make this change effective

    • Note: You should change the SQL Server Port configuration using the SQL Server Configuration Manager only.

Method 2: SQL Server Error Logs:

SQL Server logs an entry in the SQL Server Error logs on each restart of SQL Services. We can use extended stored procedure xp_readerrorlog to filter the error log using a particular keyword.

The following query uses extended stored procedure xp_readerrorlog to check for the Server is listening on a keyword.

1

2

3

EXEC xp_ReadErrorLog 0, 1, N'Server is listening on', N'any', NULL, NULL, 'DESC'

GO

You get the detail of the SQL Server port on which current SQL Server instance is configured.

  • Note: If you are recycling error logs regularly, you might not be able to find SQL Server Port using this method.

Method 3: Get SQL Server Port from the registry using xp_instance_regread:

We can use an extended stored procedure to get the SQL Port value. Execute the following code in SSMS to get a dynamic port for the currently connected SQL instance.

1

2

3

4

5

6

7

8

DECLARE @portNumber NVARCHAR(10);

EXEC xp_instance_regread

@rootkey = 'HKEY_LOCAL_MACHINE',

@key = 'Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IpAll',

@value_name = 'TcpDynamicPorts',

@value = @portNumber OUTPUT;

SELECT [Port Number] = @portNumber;

GO

Overview of SQL Server Ports (7)

We can use @Value_name=’ TcpPort’ to get detail about the static port.

1

2

3

4

5

6

7

8

DECLARE @portNumber NVARCHAR(10);

EXEC xp_instance_regread

@rootkey = 'HKEY_LOCAL_MACHINE',

@key = 'Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IpAll',

@value_name = 'TcpPorts',

@value = @portNumber OUTPUT;

SELECT [Port Number] = @portNumber;

GO

Method 4: Get SQL Server Port from using sys.dm_exec_connections DMV:

We can use sys.dm_exec_connections DMV to check for the TCP port of connected SQL Server instance. We use the @@SPID variable to return the current session SP ID.

1

2

3

4

SELECT local_tcp_port

FROM sys.dm_exec_connections

WHERE session_id = @@SPID;

GO

Overview of SQL Server Ports (8)

Method 5: Get SQL Server Port from using the Windows Event Viewer:

We can use Windows Event Viewer as well to check for the SQL Server Port details. Once we restart SQL Services, Windows Event Viewer also gets an entry for the SQL Port. Windows Event Viewer might have a large number of events. It is better to filter event logs for event id 26022.

Go to Run and type eventvwr. It opens the windows event viewer console. Click on – Filter Current Log.

Specify the event ID 26022 and click OK

Overview of SQL Server Ports (10)

The Event viewer shows events for all installed SQL Servers in the servers. You can look for a specific instance and check for the port number.

You can also select a specific SQL instance in the drop-down list of Event Sources.

Overview of SQL Server Ports (11)

In the following screenshot, we can see an entry of SQL Server Port in the Windows event viewer.

Overview of SQL Server Ports (12)

Conclusion

In this article, we explored and identify methods to check SQL Server Ports and change the static and dynamic port configuration. If you have any comments or questions, feel free to leave them in the comments below.

  • Author
  • Recent Posts

Rajendra Gupta

Hi! I am Rajendra Gupta, Database Specialist and Architect, helping organizations implement Microsoft SQL Server, Azure, Couchbase, AWS solutions fast and efficiently, fix related issues, and Performance Tuning with over 14 years of experience.

I am the author of the book "DP-300 Administering Relational Database on Microsoft Azure". I published more than 650 technical articles on MSSQLTips, SQLShack, Quest, CodingSight, and SeveralNines.

I am the creator of one of the biggest free online collections of articles on a single topic, with his 50-part series on SQL Server Always On Availability Groups.

Based on my contribution to the SQL Server community, I have been recognized as the prestigious Best Author of the Year continuously in 2019, 2020, and 2021 (2nd Rank) at SQLShack and the MSSQLTIPS champions award in 2020.

Personal Blog: https://www.dbblogger.com
I am always interested in new challenges so if you need consulting help, reach me at rajendra.gupta16@gmail.com

View all posts by Rajendra Gupta

Latest posts by Rajendra Gupta (see all)

  • How to install PostgreSQL on Ubuntu - July 13, 2023
  • How to use the CROSSTAB function in PostgreSQL - February 17, 2023
  • Learn the PostgreSQL COALESCE command - January 19, 2023

Related posts:

  1. Overview of SQL Server Aliases
  2. Overview of SQL Server Startup Parameters for the SQL Database Engine Service
  3. SQL Server network configuration
  4. Overview of Service Principal Name and Kerberos authentication in SQL Server
  5. SQL Server 2019 overview and installation
Overview of SQL Server Ports (2024)
Top Articles
8 Shared Traits of Daughters Abandoned by Fathers
How to override the CSS properties of a class using another CSS class ? - GeeksforGeeks
Is Sam's Club Plus worth it? What to know about the premium warehouse membership before you sign up
Chicago Neighborhoods: Lincoln Square & Ravenswood - Chicago Moms
From Algeria to Uzbekistan-These Are the Top Baby Names Around the World
Overnight Cleaner Jobs
Retro Ride Teardrop
Noaa Swell Forecast
Gameplay Clarkston
Best Cav Commanders Rok
Morgan Wallen Pnc Park Seating Chart
Large storage units
Hallelu-JaH - Psalm 119 - inleiding
Ree Marie Centerfold
Notisabelrenu
Scenes from Paradise: Where to Visit Filming Locations Around the World - Paradise
Bitlife Tyrone's
Daily Voice Tarrytown
Craigslist Maui Garage Sale
How your diet could help combat climate change in 2019 | CNN
Azur Lane High Efficiency Combat Logistics Plan
Craigslist Apartments Baltimore
[PDF] PDF - Education Update - Free Download PDF
Craigslist Roseburg Oregon Free Stuff
Delta Math Login With Google
49S Results Coral
The Bold and the Beautiful
Frequently Asked Questions - Hy-Vee PERKS
Fbsm Greenville Sc
3400 Grams In Pounds
Henry County Illuminate
Cherry Spa Madison
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
Craigslist en Santa Cruz, California: Tu Guía Definitiva para Comprar, Vender e Intercambiar - First Republic Craigslist
Mississippi weather man flees studio during tornado - video
ESA Science & Technology - The remarkable Red Rectangle: A stairway to heaven? [heic0408]
The Attleboro Sun Chronicle Obituaries
FREE - Divitarot.com - Tarot Denis Lapierre - Free divinatory tarot - Your divinatory tarot - Your future according to the cards! - Official website of Denis Lapierre - LIVE TAROT - Online Free Tarot cards reading - TAROT - Your free online latin tarot re
Free Crossword Puzzles | BestCrosswords.com
Levi Ackerman Tattoo Ideas
Oklahoma City Farm & Garden Craigslist
Phmc.myloancare.com
The Machine 2023 Showtimes Near Roxy Lebanon
Craigslist Sarasota Free Stuff
Electric Toothbrush Feature Crossword
Skyward Login Wylie Isd
David Turner Evangelist Net Worth
How to Get a Check Stub From Money Network
Provincial Freeman (Toronto and Chatham, ON: Mary Ann Shadd Cary (October 9, 1823 – June 5, 1893)), November 3, 1855, p. 1
Coldestuknow
Affidea ExpressCare - Affidea Ireland
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 6162

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.