How to Identify port number of SQL server

SqlSql Server

Sql Problem Overview


I Install SQL server in my system and I have to check on which port number SQL is working in my system

Sql Solutions


Solution 1 - Sql

  1. Open SQL Server Management Studio

  2. Connect to the database engine for which you need the port number

  3. Run the below query against the database

    select distinct local_net_address, local_tcp_port from sys.dm_exec_connections where local_net_address is not null

The above query shows the local IP as well as the listening Port number

Solution 2 - Sql

  1. Open Run in your system.

  2. Type %windir%\System32\cliconfg.exe

  3. Click on ok button then check that the "TCP/IP Network Protocol Default Value Setup" pop-up is open.

  4. Highlight TCP/IP under the Enabled protocols window.

  5. Click the Properties button.

  6. Enter the new port number, then click OK.

enter image description here

Solution 3 - Sql

You can also use this query

USE MASTER GO xp_readerrorlog 0, 1, N'Server is listening on' GO

Source : sqlauthority blog

Solution 4 - Sql

Visually you can open "SQL Server Configuration Manager" and check properties of "Network Configuration":

SQL Server Configuration

Solution 5 - Sql

This query works for me:

SELECT DISTINCT 
    local_tcp_port 
FROM sys.dm_exec_connections 
WHERE local_tcp_port IS NOT NULL 

Solution 6 - Sql

To check all the applications listening on all ports, there is command:

netstat -ntpl

Solution 7 - Sql

PowerShell solution that shows all of the instances on the host as well as their incoming traffic addresses. The second bit might be helpful if all you know is the DNS:

ForEach ($SQL_Proc in Get-Process | Select-Object -Property ProcessName, Id | Where-Object {$_.ProcessName -like "*SQL*"})
{
    Get-NetTCPConnection | `
     Where-Object {$_.OwningProcess -eq $SQL_Proc.id} | `
      Select-Object -Property `
                                @{Label ="Process_Name";e={$SQL_Proc.ProcessName}}, `
                                @{Label ="Local_Address";e={$_.LocalAddress + ":" + $_.LocalPort }},  `
                                @{Label ="Remote_Address";e={$_.RemoteAddress + ":" + $_.RemotePort}}, State | `
      Format-Table
} 

Solution 8 - Sql

if you are able to login in just use

select @@port;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnkit jainView Question on Stackoverflow
Solution 1 - SqlPunter015View Answer on Stackoverflow
Solution 2 - SqlAnkit jainView Answer on Stackoverflow
Solution 3 - SqlSunil AgarwalView Answer on Stackoverflow
Solution 4 - SqlYuriy GalanterView Answer on Stackoverflow
Solution 5 - SqlUnsal AslanView Answer on Stackoverflow
Solution 6 - SqlPacoView Answer on Stackoverflow
Solution 7 - SqlBartosz XView Answer on Stackoverflow
Solution 8 - SqlPrajwal Raju PView Answer on Stackoverflow