How can I find out the port number being used by my instance of MS SQL Server Express?

1 minute read time.

This article is a child of frustration.  I made the decision to completely remove CRM from one of my machines and then got stuck because I had no idea what port my target SQL Server was listening on.  

Note: By default, MS SQL Server Express uses port 1433.  But in my case, this wasn't true and so I had to find a way of establishing the port being used.

So, just for reference.

We can find out the port number being used by an instance of MS SQL Server Express in a couple of ways.

  1. We can use the Configuration Manager
  2. We can use a T-SQL query.

Using the Configuration Manager

Note:  You can access the Configuration Manager through the Windows Start menu by searching for "SQL Server Configuration Manager."  BUT if the SQL Configuration Manager does not show in your Windows menus then navigate to c:\windows\system32 and look for a file with the name "SQLServerManagerxx.msc", where xx is the version of SQL Server you have installed. E.g for SQL Server 2019, the name is SQLServerManager15.msc. Double-click it and it will open. You can also make a shortcut on the desktop.

  1. In SQL Server Configuration Manager, expand the "SQL Server Network Configuration" node and select "Protocols for [instance name]".
  2. In the right-hand pane, you should see a list of protocols. Look for the TCP/IP protocol and make sure it is enabled.
  3. Right-click on the TCP/IP protocol and select "Properties."
  4. In the TCP/IP Properties dialog box, select the "IP Addresses" tab.
  5. Scroll down to the "IPAll" section and look for the "TCP Port" field. This is the port number being used by your instance of MS SQL Server Express.

Using T-SQL to find out the port used.

If you prefer to use T-SQL you can query the server properties.

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

This will return the port number being used for TCP/IP connections by the SQL Server instance.