Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Tcp port is already in use.How do I check if a port is already in use?

20 February,2023 by Tom Collins

Question: SQL Server won't start , so checked Event Viewer and getting the following message. 

Server TCP provider failed to listen on [ 'any' <ipv4> 50010]. Tcp port is already in use.

How can I check if the port is already in use and which other process or service  has locked the port and therefore not allowing SQL Server to start on designated port ?

Answer:

The  first thing to identify is the Owning process and check the Process Name . There are different methods to list the processes currently using (or not using) the port. 

I like using Powershell for investing Windows related issues . Here is a Powershell script that  will either return the : Local Address, Local Port ,Remote Address,Remote Port ,State ,Applied Setting , Owning Process 

or if there are no processes utilising the port - return a  message 

The TCP connections are returned by the Get-NetTCPConnection powershell cmdlet. 

cls
$TcpPort = "50010"
$TcpConn = Get-NetTCPConnection | Where-Object {$_.LocalPort -eq $TcpPort -or $_.RemotePort -eq $TcpPort}
$TcpConn
$process = $TcpConn | Select-Object OwningProcess -Unique
if ($process -ne $null)
{
    Get-Process | Where-Object {$_.id -eq $process.OwningProcess} | Select-Object Id, ProcessName
}
else
{
    write-output "No services\processes discovered using the port"
}

read more on ports 

How to find SQL Server tcp port with Powershell

How to find the local tcp port used on SQL Server

Change the port for sql server service broker

How to get SQL port number using xp_readererrorlog

How to configure SQL Server static port with Powershell


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Tcp port is already in use.How do I check if a port is already in use?


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer