What port number does my SQL Server listen on?

Looking for an easy way to know what port number your SQL Server is listening on? You can of course go to the Configuration Manager or check through the registry… but an even simpler way is to query the view SYS.DM_EXEC_CONNECTIONS which will tell you provided you’re connected over TCP/IP

SELECT @@SERVERNAME As SqlServer,
LOCAL_NET_ADDRESS AS 'SqlServerIP',
LOCAL_TCP_PORT AS 'Port'

FROM SYS.DM_EXEC_CONNECTIONS WHERE SESSION_ID = @@SPID

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.