Yes, you read that right. The port you’re trying to use is already occupied by another application. If you’re a system or network administrator, you’ve likely encountered this frustrating message more times than you care to remember. It’s challenging to pinpoint which application is hogging the port (though it’s not as hard as it seems, as I’ll show you 😉). These ghost messages can leave you in quite a pickle.
Just yesterday, we faced this exact issue and wasted two hours troubleshooting so that you don’t have to!
Our situation was this: We had installed SQL Server 2019 Reporting Services on one of our development servers, and the default port it selected for installation was 8082
. Unfortunately, this port was already in use by our front-facing application, so we needed to free it up.
After some frantic Googling, we found a solution: we updated the port from 8082
to 8083
in the config.json
file located in the Reporting Services folder. (You can usually find the file here: C:\Program Files\Microsoft SQL Server Reporting Services\SSRS\RSHostingService\RSHostingService.exe
.) We then restarted the SQL Server Reporting Services
Windows service, and voilà—RSHostingService.exe
started running on port 8083
.
We thought everything was resolved and that port 8082
was free. However, when we configured our front-end application and tried to access it, we were greeted with a 503 Server Unavailable
error. 😢
Troubleshooting Port Availability
To narrow down the issue, it’s helpful to identify which application is using the port.
Finding the Process Using netstat
The netstat command, short for “network statistics,” is a command-line tool that displays active network connections, routing tables, and various network interface statistics. By running the netstat
command with the noa
parameters, we can list all the listening ports with process ID information and pipe that command to search for the specific port.
|
|
Output:
|
|
The process ID 4
indicates that it’s a system process. Unfortunately, this doesn’t tell us which application is using the port, so we need another method.
Finding the Process Using netsh
Netsh, short for Network Shell, is a command-line utility that allows users to configure and manage network devices both locally and remotely. It’s particularly useful for tasks like changing IP addresses, resetting the TCP/IP stack, and managing wireless settings.
We can use netsh
to query the HTTP request and find out which process is using port 8082
:
|
|
Save the output of the above command to a file, open it using Notepad, and search for the port details:
|
|
Output:
|
|
Now you can see that port 8082
is being used by process 2312
. You can check Task Manager to see which process is associated with this PID, or use the following command:
|
|
Output:
|
|
What the Heck?! 😮
How is this possible? We changed the reporting tool config file, yet netsh
still shows that port 8082
is in use. Upon rechecking the reporting service logs, we confirmed that the application is indeed running on port 8083
. 🤔
It turns out that the URL with port 8082
was reserved by SQL Reporting Services with an Access Control List (ACL) during installation. Changing the config file alone wasn’t enough. To see the list of URL reservations for HTTP services, use this command:
|
|
Output:
|
|
To free up port 8082
for our front-end application, we needed to delete this obsolete HTTP reservation:
|
|
Output:
|
|
To confirm that the port is free and available for use, run:
|
|
The expected output should be blank! 😉
Finally, the port is free!