{"id":41394,"date":"2026-11-26T22:04:41","date_gmt":"2026-11-26T22:04:41","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=41394"},"modified":"2026-11-26T22:04:41","modified_gmt":"2026-11-26T22:04:41","slug":"windows-troubleshooting-administrator-guide","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/windows-troubleshooting-administrator-guide\/","title":{"rendered":"Windows Troubleshooting: Administrator Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To find which ports are in use on Windows, use <code>netstat -ano<\/code> in Command Prompt, <code>Get-NetTCPConnection<\/code> and <code>Get-NetUDPEndpoint<\/code> in PowerShell, or the graphical tools Resource Monitor and TCPView. This guide shows those methods, then explains how to read the output, match a port to its process or service, fix port conflicts and test whether a port can be reached.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How to check for used ports on Windows?<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Using Command Prompt<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Netstat<\/strong>: This command displays active connections and listening ports.\n<ul class=\"wp-block-list\">\n<li>Open Command Prompt (you can search for <code>cmd<\/code> in the Start menu).<\/li>\n\n\n\n<li>Type <code>netstat -ano<\/code> and press Enter. This will list all ports in use along with the process IDs (PIDs) using them.<\/li>\n\n\n\n<li>To find a specific port, you can use <code>netstat -ano | findstr \"PORT_NUMBER\"<\/code>, replacing <code>PORT_NUMBER<\/code> with the port you&#8217;re interested in.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>TCPView<\/strong>: This is a graphical utility from Sysinternals that provides a more detailed view of TCP and UDP endpoints. You need to download it from Microsoft&#8217;s website.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Using PowerShell<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open PowerShell (you can search for <code>powershell<\/code> in the Start menu).<\/li>\n\n\n\n<li>Run the following command: <code>Get-NetTCPConnection | Where-Object { $_.LocalPort -eq PORT_NUMBER }<\/code>, replacing <code>PORT_NUMBER<\/code> with the port you want to check.<\/li>\n\n\n\n<li>Alternatively, you can use <code>Get-Process -Id (Get-NetTCPConnection -LocalPort PORT_NUMBER).OwningProcess<\/code> to get more information about the process that&#8217;s using the port.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Using Resource Monitor<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open Resource Monitor, which can be found by searching in the Start menu or under the &#8220;Performance&#8221; tab of Task Manager.<\/li>\n\n\n\n<li>Go to the &#8220;Network&#8221; tab.<\/li>\n\n\n\n<li>Look at the &#8220;Listening Ports&#8221; section to see which ports are in use and by which processes.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"521\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/11\/image-41-1024x521.png\" alt=\"Windows Resource Monitor Network tab with Listening Ports listing processes, PIDs and ports in use\" class=\"wp-image-41395\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/11\/image-41-1024x521.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/11\/image-41-300x153.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/11\/image-41-768x391.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/11\/image-41-1536x781.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/11\/image-41.png 1998w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Reading netstat output<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>netstat -ano<\/code> prints one line per socket. <code>-a<\/code> shows all connections and listening ports, <code>-n<\/code> shows numbers instead of host and service names (much faster), and <code>-o<\/code> adds the owning process ID. A typical result looks like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\">  <span class=\"hljs-selector-tag\">Proto<\/span>  <span class=\"hljs-selector-tag\">Local<\/span> <span class=\"hljs-selector-tag\">Address<\/span>          <span class=\"hljs-selector-tag\">Foreign<\/span> <span class=\"hljs-selector-tag\">Address<\/span>        <span class=\"hljs-selector-tag\">State<\/span>           <span class=\"hljs-selector-tag\">PID<\/span>\n  <span class=\"hljs-selector-tag\">TCP<\/span>    0<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-pseudo\">:135<\/span>            0<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-pseudo\">:0<\/span>              <span class=\"hljs-selector-tag\">LISTENING<\/span>       1032\n  <span class=\"hljs-selector-tag\">TCP<\/span>    0<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-pseudo\">:445<\/span>            0<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-pseudo\">:0<\/span>              <span class=\"hljs-selector-tag\">LISTENING<\/span>       4\n  <span class=\"hljs-selector-tag\">TCP<\/span>    127<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.1<\/span><span class=\"hljs-selector-pseudo\">:5432<\/span>         0<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-pseudo\">:0<\/span>              <span class=\"hljs-selector-tag\">LISTENING<\/span>       3920\n  <span class=\"hljs-selector-tag\">TCP<\/span>    192<span class=\"hljs-selector-class\">.168<\/span><span class=\"hljs-selector-class\">.1<\/span><span class=\"hljs-selector-class\">.20<\/span><span class=\"hljs-selector-pseudo\">:52144<\/span>     20<span class=\"hljs-selector-class\">.190<\/span><span class=\"hljs-selector-class\">.151<\/span><span class=\"hljs-selector-class\">.7<\/span><span class=\"hljs-selector-pseudo\">:443<\/span>       <span class=\"hljs-selector-tag\">ESTABLISHED<\/span>     8812\n  <span class=\"hljs-selector-tag\">TCP<\/span>    <span class=\"hljs-selector-attr\">&#91;::]<\/span><span class=\"hljs-selector-pseudo\">:80<\/span>                <span class=\"hljs-selector-attr\">&#91;::]<\/span><span class=\"hljs-selector-pseudo\">:0<\/span>                 <span class=\"hljs-selector-tag\">LISTENING<\/span>       4\n  <span class=\"hljs-selector-tag\">UDP<\/span>    0<span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-class\">.0<\/span><span class=\"hljs-selector-pseudo\">:5353<\/span>           *:*                                    2460<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Value<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td><code>0.0.0.0:PORT<\/code> or <code>[::]:PORT<\/code><\/td><td>Listening on every IPv4 or IPv6 interface, so other machines can reach it unless the firewall blocks it<\/td><\/tr><tr><td><code>127.0.0.1:PORT<\/code><\/td><td>Listening only on loopback, so only the local machine can connect<\/td><\/tr><tr><td><code>LISTENING<\/code><\/td><td>A server socket waiting for connections. This is usually what blocks another app from using the port<\/td><\/tr><tr><td><code>ESTABLISHED<\/code><\/td><td>An active connection. The local port is often a random high (ephemeral) port<\/td><\/tr><tr><td><code>TIME_WAIT<\/code><\/td><td>A recently closed connection. It clears on its own and shows PID 0<\/td><\/tr><tr><td><code>CLOSE_WAIT<\/code><\/td><td>The remote side closed the connection but the local app has not. Many of these usually mean an application bug<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">UDP has no connections, so UDP lines have no state. To list one protocol only, use <code>netstat -ano -p TCP<\/code> or <code>netstat -ano -p UDP<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Corrected port lookup commands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some commands in the example above give misleading results. <code>findstr &quot;80&quot;<\/code> matches any line that contains those digits, including ports 8080 and 3380 and PIDs such as 1804. Search for the colon, the port and the space after it instead. <code>\/C:<\/code> makes findstr treat the space as part of the search text rather than a separator:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">netstat -ano | findstr \/C:<span class=\"hljs-string\">\":8080 \"<\/span>\n\nrem Only listening sockets on that port\nnetstat -ano | findstr \/C:<span class=\"hljs-string\">\":8080 \"<\/span> | findstr LISTENING<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">In PowerShell, filter with parameters instead of piping every connection through <code>Where-Object<\/code>. Add <code>-State Listen<\/code> to skip client connections. Add <code>-ErrorAction SilentlyContinue<\/code> because the cmdlet throws an error when nothing matches. <code>Select-Object -Unique<\/code> stops the same process appearing once for every connection:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># TCP listener on a port<\/span>\nGet-NetTCPConnection -LocalPort <span class=\"hljs-number\">8080<\/span> -State Listen -ErrorAction SilentlyContinue\n\n<span class=\"hljs-comment\"># Process behind it (safe when nothing is found or many connections exist)<\/span>\n$pids = (Get-NetTCPConnection -LocalPort <span class=\"hljs-number\">8080<\/span> -ErrorAction SilentlyContinue).OwningProcess |\n    Select-Object -Unique\n<span class=\"hljs-keyword\">if<\/span> ($pids) { Get-Process -Id $pids } <span class=\"hljs-keyword\">else<\/span> { <span class=\"hljs-string\">'Port 8080 is not in use (TCP)'<\/span> }\n\n<span class=\"hljs-comment\"># UDP is separate: Get-NetTCPConnection never shows UDP ports<\/span>\nGet-NetUDPEndpoint -LocalPort <span class=\"hljs-number\">53<\/span> -ErrorAction SilentlyContinue<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <code>Get-NetTCPConnection<\/code> and <code>Get-NetUDPEndpoint<\/code> come from the NetTCPIP module. They are available in Windows PowerShell 5.1 and in PowerShell 7 on Windows, but not on Linux or macOS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Listing every listening port with its process name<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use this report for a quick audit of a server. It shows every TCP listener and UDP endpoint with the process name, sorted by port:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$tcp = Get-NetTCPConnection -State Listen | <span class=\"hljs-keyword\">ForEach<\/span>-Object {\n    &#91;pscustomobject]@{\n        Proto   = <span class=\"hljs-string\">'TCP'<\/span>\n        Address = $_.LocalAddress\n        Port    = $_.LocalPort\n        PID     = $_.OwningProcess\n        Process = (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName\n    }\n}\n$udp = Get-NetUDPEndpoint | <span class=\"hljs-keyword\">ForEach<\/span>-Object {\n    &#91;pscustomobject]@{\n        Proto   = <span class=\"hljs-string\">'UDP'<\/span>\n        Address = $_.LocalAddress\n        Port    = $_.LocalPort\n        PID     = $_.OwningProcess\n        Process = (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName\n    }\n}\n$tcp + $udp | Sort-Object Proto, Port | Format-Table -AutoSize<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To save the report or compare it with another server, replace <code>Format-Table -AutoSize<\/code> with <code>Export-Csv .\\ports.csv -NoTypeInformation<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Finding the process, service or command line behind a PID<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">netstat only gives you a number. The example above does not show how to turn that number into a process in Command Prompt. Use <code>tasklist<\/code> with a filter:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">rem Process name <span class=\"hljs-keyword\">for<\/span> PID <span class=\"hljs-number\">1032<\/span>\ntasklist \/FI <span class=\"hljs-string\">\"PID eq 1032\"<\/span>\n\nrem Services hosted inside that process (useful <span class=\"hljs-keyword\">for<\/span> svchost.exe)\ntasklist \/svc \/FI <span class=\"hljs-string\">\"PID eq 1032\"<\/span>\n\nrem Show the executable name next to each socket (needs an elevated prompt)\nnetstat -abno<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Many Windows services share a single <code>svchost.exe<\/code> process, so the process name alone is often not enough. In PowerShell you can see the full command line and any services in the process:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Get-CimInstance Win32_Process -Filter <span class=\"hljs-string\">\"ProcessId = 1032\"<\/span> |\n    Select-<span class=\"hljs-built_in\">Object<\/span> ProcessId, Name, ExecutablePath, CommandLine\n\nGet-CimInstance Win32_Service -Filter <span class=\"hljs-string\">\"ProcessId = 1032\"<\/span> |\n    Select-<span class=\"hljs-built_in\">Object<\/span> Name, DisplayName, State, StartMode<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Run the console as Administrator. Without elevation, <code>netstat -b<\/code> fails and some processes show no path or command line because you do not have permission to see them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common port problems and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Likely cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Port shows PID 4 (<code>System<\/code>)<\/td><td>The kernel owns it. Usually HTTP.sys (IIS, WinRM, WCF or other apps that reserve URLs), or SMB on 445<\/td><td>Run <code>netsh http show servicestate<\/code> to see which app registered the URL, then stop that service (for example <code>W3SVC<\/code> for IIS) or change its binding<\/td><\/tr><tr><td>App says the port is in use but nothing is listening on it<\/td><td>Windows has reserved the port range, often because of Hyper-V, WSL 2, Docker or WinNAT<\/td><td>Run <code>netsh interface ipv4 show excludedportrange protocol=tcp<\/code> and choose a port outside the reserved ranges<\/td><\/tr><tr><td>Many <code>TIME_WAIT<\/code> entries with PID 0<\/td><td>Normal after short connections close<\/td><td>No action needed unless ephemeral ports run out. Reuse connections in the client<\/td><\/tr><tr><td><code>No MSFT_NetTCPConnection objects found<\/code><\/td><td>Nothing is using that port<\/td><td>Add <code>-ErrorAction SilentlyContinue<\/code> or treat the error as &quot;port is free&quot;<\/td><\/tr><tr><td>Port is listening but remote clients cannot connect<\/td><td>It is bound to <code>127.0.0.1<\/code>, or Windows Firewall blocks it<\/td><td>Bind to <code>0.0.0.0<\/code> or the server IP, then check the firewall rules (see the next section)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Freeing a port safely<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Find the PID with <code>netstat -ano | findstr \/C:&quot;:8080 &quot;<\/code> or <code>Get-NetTCPConnection -LocalPort 8080<\/code>.<\/li>\n\n\n<li>Check whether the PID belongs to a service: <code>tasklist \/svc \/FI &quot;PID eq &lt;PID&gt;&quot;<\/code>.<\/li>\n\n\n<li>If it is a service, stop it properly so it does not just restart: <code>Stop-Service -Name &lt;ServiceName&gt;<\/code>. To stop it starting at boot, also run <code>Set-Service -Name &lt;ServiceName&gt; -StartupType Disabled<\/code>.<\/li>\n\n\n<li>If it is an ordinary application, close it normally first. Force it closed only if you must: <code>Stop-Process -Id &lt;PID&gt;<\/code> or <code>taskkill \/PID &lt;PID&gt; \/F<\/code>.<\/li>\n\n\n<li>Check that the port is free with <code>Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue<\/code>. An empty result means nothing is using it.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Do not end PID 4, <code>lsass.exe<\/code>, <code>wininit.exe<\/code> or <code>services.exe<\/code>. Ending these crashes or restarts the system. Stop the service that registered the port instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing whether a port is reachable<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A port can be listening on the server and still be unreachable from other machines. Test from the client side with <code>Test-NetConnection<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Test-NetConnection -ComputerName server01 -Port <span class=\"hljs-number\">443<\/span>\n\n<span class=\"hljs-comment\"># Relevant part of the output<\/span>\n<span class=\"hljs-comment\"># RemoteAddress    : 10.0.0.15<\/span>\n<span class=\"hljs-comment\"># RemotePort       : 443<\/span>\n<span class=\"hljs-comment\"># TcpTestSucceeded : True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If <code>TcpTestSucceeded<\/code> is <code>False<\/code> but the server shows the port as <code>LISTENING<\/code> on <code>0.0.0.0<\/code>, check the server&#039;s firewall for a rule that allows the port:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Get-NetFirewallPortFilter -Protocol TCP |\n    Where-Object LocalPort -eq <span class=\"hljs-number\">8080<\/span> |\n    Get-NetFirewallRule |\n    Select-Object DisplayName, Enabled, Direction, Action, Profile\n\n<span class=\"hljs-comment\"># Allow the port inbound if no rule exists (elevated prompt)<\/span>\n<span class=\"hljs-keyword\">New<\/span>-NetFirewallRule -DisplayName <span class=\"hljs-string\">'App 8080'<\/span> -Direction Inbound -Protocol TCP -LocalPort <span class=\"hljs-number\">8080<\/span> -Action Allow<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Only open the ports a service needs, and limit the rule with <code>-RemoteAddress<\/code> or <code>-Profile Domain<\/code> where you can. Use the listening-ports report above to find services that are exposed by mistake. More cmdlets are covered in the <a href=\"https:\/\/www.devopsschool.com\/blog\/powershell-tutorials-command-line-reference\/\">PowerShell command line reference<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">How do I kill the process using a port on Windows?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Find the PID with <code>netstat -ano | findstr \/C:&quot;:PORT &quot;<\/code>, then run <code>taskkill \/PID &lt;PID&gt; \/F<\/code> or <code>Stop-Process -Id &lt;PID&gt;<\/code>. If the PID belongs to a service, stop the service with <code>Stop-Service<\/code> instead, or it may start again.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why is port 80 or 443 used by PID 4 (System)?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PID 4 is the Windows kernel. A web port held by PID 4 usually means HTTP.sys has registered it for IIS, WinRM or another app that uses HTTP.sys. Run <code>netsh http show servicestate<\/code> to see which process registered the URL.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need administrator rights to check open ports?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. <code>netstat -ano<\/code> and <code>Get-NetTCPConnection<\/code> work in a normal console. You need an elevated prompt for <code>netstat -b<\/code>, which shows executable names, and to see details of processes run by other users or SYSTEM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does Windows say a port is in use when netstat shows nothing on it?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Windows may have reserved the port in an excluded range, often for Hyper-V, WSL 2 or Docker networking. Run <code>netsh interface ipv4 show excludedportrange protocol=tcp<\/code> to see the reserved ranges, and choose a port outside them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I check if a port is open on a remote Windows server?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>Test-NetConnection -ComputerName &lt;host&gt; -Port &lt;port&gt;<\/code> from the client and look at <code>TcpTestSucceeded<\/code>. If it is False, check that the service is listening on a reachable address and that the server&#039;s firewall allows the port.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/powershell-tutorials-command-line-reference\/\">Powershell Tutorials: Command Line reference<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/windows-administrator-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Windows Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/operating-systems\/windows\/\">More Windows tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To find which ports are in use on Windows, use netstat -ano in Command Prompt, Get-NetTCPConnection and Get-NetUDPEndpoint in PowerShell, or the graphical tools Resource Monitor and&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[55],"tags":[1840,26300],"class_list":["post-41394","post","type-post","status-publish","format-standard","hentry","category-windows","tag-powershell","tag-tcp-ip"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=41394"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41394\/revisions"}],"predecessor-version":[{"id":80291,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41394\/revisions\/80291"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=41394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=41394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=41394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}