Windows 10 - Close listening ports

Abstract: Resolve Windows 10 port conflicts by identifying the process ID via netstat and terminating it with taskkill to free the listening port.

Created: 2026-10-01 by

To close listening ports in Windows 10, you must identify the specific process using the port via the netstat command and then terminate that process. You cannot simply "close" a port directly; instead, stopping the application bound to it frees the port. This ensures better system security and network performance by removing unnecessary background services.

Identify the Process Using the Port

The first step in managing open ports is determining which application is holding them. The netstat utility provides a detailed view of all active connections and listening ports on your system. Open the Command Prompt as an administrator to ensure you have access to all necessary network information. Click the Start menu, type cmd, right-click the Command Prompt app, and select Run as administrator. Once the terminal is open, enter the following command to list all listening ports along with their associated Process IDs (PIDs):
netstat -ano | findstr LISTENING
This command filters the output to show only ports in the LISTENING state. The output will display four columns: Protocol, Local Address, Foreign Address, and State, followed by the PID at the end of each line. For example, you might see a line like:
TCP    0.0.0.0:445    0.0.0.0:0    LISTENING    4
In this example, port 445 is being used by the process with PID 4. Note down the PID corresponding to the port you wish to close. If you need more details about the local address, such as the IP version or specific interface, you can use netstat -bano, but this requires higher privileges and may take longer to execute as it attempts to resolve the executable name for each connection.

Map the PID to a Specific Application

Knowing the PID is useful, but you need to know which program it belongs to before terminating it. Use the tasklist command to map the PID to a process name. Run the following command in the same administrator Command Prompt window:
tasklist /FI "PID eq [PID]"
Replace [PID] with the actual number you identified in the previous step. For instance, if the PID was 4, you would run:
tasklist /FI "PID eq 4"
The output will show the image name (the executable file), PID, session name, session number, and memory usage. Common processes that hold ports include svchost.exe (for various Windows services), System (kernel-level processes), or third-party applications like web servers or database managers. Be cautious when identifying system processes, as terminating critical Windows services can cause instability. If you are unsure about a process, research its function online before proceeding. For more complex system issues, you might also want to check out How to Fix Hard Drive Issues on Windows 7 and Windows 10 to ensure your system integrity is maintained alongside network configurations.

Terminate the Process

Once you have confirmed the application responsible for the port, you can terminate it using the taskkill command. To forcefully end the process, use the following syntax:
taskkill /PID [PID] /F
The /F flag forces the termination of the process. Without it, the application might ignore the request if it has pending operations. After running this command, verify that the port is no longer listening by running the initial netstat command again. If the port is gone, the action was successful. If the process restarts automatically (common with Windows services), you may need to disable the service entirely. Open the Services manager by typing services.msc in the Run dialog. Locate the service associated with the terminated process, double-click it, and change the Startup Type to Disabled. Then, stop the service if it is currently running. This prevents the port from reopening after a reboot or due to automatic service recovery.

Verify and Monitor Ports

After closing the port, it is good practice to monitor your system to ensure no other unexpected ports are open. Regularly checking listening ports helps maintain a secure environment. You can create a simple batch script to automate this check. Save the following code as check_ports.bat:
@echo off
netstat -ano | findstr LISTENING
pause
Running this script will quickly display all current listening ports and their PIDs, allowing for quick audits. Additionally, consider using Windows Defender Firewall to block incoming connections to specific ports even if the application is still running, providing an extra layer of security. For users experiencing connectivity issues that might be related to port conflicts, reviewing Troubleshooting Slow Connecting Times for Remote Desktop on Windows 10 can provide further insights into network optimization.

Frequently Asked Questions

Can I close a port without killing the process?

No, you cannot directly close a port while an application is actively bound to it. You must either stop the application or configure it to release the port. However, you can use the Windows Firewall to block traffic to the port, effectively making it inaccessible from the network while the process continues to run locally.

What if the process refuses to terminate?

If taskkill /F fails, the process might be protected by the operating system or stuck in a hung state. In such cases, you may need to boot into Safe Mode and attempt the termination again, or use third-party tools like Process Explorer to force kill stubborn processes. Always back up your work before forcing termination.

Is it safe to close port 445?

Port 445 is used for SMB (Server Message Block) file sharing. Closing it will disable file and printer sharing over the network. If you do not use network sharing, it is generally safer to leave it closed or blocked by the firewall to prevent exploitation by malware like WannaCry.

How do I permanently prevent a port from reopening?

To prevent a port from reopening, you must disable the service or application that binds to it. Go to services.msc, find the relevant service, set its startup type to Disabled, and stop it. Alternatively, uninstall the software if it is no longer needed.

Why does netstat show many listening ports?

Windows 10 runs numerous background services by default, including updates, telemetry, and networking features. Each service may bind to one or more ports. This is normal behavior. Only investigate ports associated with unknown PIDs or those you did not intentionally install.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More