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
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |