Windows освободить tcp порт

Формулировка вопроса напрашивается на соотвествующий ответ…
Но если по существу — узнать какая программа занимает порт можно
netstat -aon | findstr 8080
потом
tasklist /fi «PID eq 12345»
— вместо 12345 подставить число из вывода первой команды

Что значит «очистить»? Если надо освободить, то просто прибейте процесс, который его занял.

Порт это цифра, номер.
Используется при передаче пакетов по сети. К имени пакета добавляют номер, чтобы получатель знал кому именно передать пакет.

Объясните пожалуйста как номер может «залагать»? Что вы под этим подразумеваете?

Как очистить использующийся порт в windows?

Никак. Они все чистые. И их всего имеется 65536.

Home

network

How to Free TCP/UDP Port on Windows Using netstat and taskkill?

If a port has been pocessed by a process/application/program, you cannot listen to it. Usually, an exception of “Address in Use – cannot bind” will be thrown. That is, a port can only be used by one program at a time. If you want to free up the port, you have to figure out which program occupies it.

On windows, you can use command netstat -ano to list the process and the ports.

-a Displays all connections and listening ports.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.

If you run it, the output looks like this:

# netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       1320
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:1801           0.0.0.0:0              LISTENING       5052
  TCP    0.0.0.0:2103           0.0.0.0:0              LISTENING       5052
  TCP    0.0.0.0:2105           0.0.0.0:0              LISTENING       5052
  TCP    0.0.0.0:2107           0.0.0.0:0              LISTENING       5052
  TCP    0.0.0.0:2869           0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:2968           0.0.0.0:0              LISTENING       14048
  TCP    0.0.0.0:5040           0.0.0.0:0              LISTENING       11184
  TCP    0.0.0.0:6646           0.0.0.0:0              LISTENING       85592
  TCP    0.0.0.0:49664          0.0.0.0:0              LISTENING       784
  TCP    0.0.0.0:49665          0.0.0.0:0              LISTENING       1824
  TCP    0.0.0.0:49666          0.0.0.0:0              LISTENING       1920
  TCP    0.0.0.0:49667          0.0.0.0:0              LISTENING       3316
  TCP    0.0.0.0:49668          0.0.0.0:0              LISTENING       4276
  TCP    0.0.0.0:49671          0.0.0.0:0              LISTENING       1068
  TCP    0.0.0.0:49688          0.0.0.0:0              LISTENING       1032
  TCP    0.0.0.0:49707          0.0.0.0:0              LISTENING       5052
  TCP    127.0.0.1:4300         0.0.0.0:0              LISTENING       15296
  TCP    127.0.0.1:4301         0.0.0.0:0              LISTENING       15296
  TCP    127.0.0.1:5354         0.0.0.0:0              LISTENING       4752
  TCP    127.0.0.1:5354         127.0.0.1:49669        ESTABLISHED     4752
  TCP    127.0.0.1:5354         127.0.0.1:49670        ESTABLISHED     4752
  TCP    127.0.0.1:5939         0.0.0.0:0              LISTENING       23360
  TCP    127.0.0.1:5939         127.0.0.1:55573        ESTABLISHED     23360
  TCP    127.0.0.1:6463         0.0.0.0:0              LISTENING       20872
  TCP    127.0.0.1:27015        0.0.0.0:0              LISTENING       4760
  TCP    127.0.0.1:27015        127.0.0.1:49708        ESTABLISHED     4760
  TCP    127.0.0.1:28317        0.0.0.0:0              LISTENING       5152
  TCP    127.0.0.1:49669        127.0.0.1:5354         ESTABLISHED     4760

where we can filter by the grep command (which can be downloaded via GNU Utilities for windows) however, you can use the windows command findstr to achieve the same thing, for example,

# netstat -ano | findstr 49669
STDIN
  TCP    127.0.0.1:5354         127.0.0.1:49669        ESTABLISHED     4752
  TCP    127.0.0.1:49669        127.0.0.1:5354         ESTABLISHED     4760

The last column is the Process ID, where you can now kill the process by using taskkill /f /PID pid where /f means force.

taskkill /f /PID 4752

Of course, we can write a batch script (cmd) that uses for or the GNU-awk to filter out the last column and pipe the commands so that two steps will be merged into one. Using the AWK can be better where you can filter out the second and third column and look for the port numbers as the grep may mistakenly match the PID or the IP address when given the port number string.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading…

420 words
Last Post: The Cousins in Binary Tree
Next Post: 9 Ways On How You Can Have A High Rank In Google

The Permanent URL is: How to Free TCP/UDP Port on Windows Using netstat and taskkill? (AMP Version)

Step 1:

Open up cmd.exe (note: you may need to run it as an administrator, but this isn’t always necessary), then run the below command:

netstat -ano | findstr <Port Number>

(Replace with the port number you want, but keep the colon)

The area circled in red shows the PID (process identifier). Locate the PID of the process that’s using the port you want.

Step 2:

Next, run the following command:

taskkill /F /PID <Process Id>

Example

STEP — 1

netstat -ano | findstr 8080
TCP  0.0.0.0:18080    0.0.0.0:0     LISTENING    19788
TCP  [::]:18080       [::]:0        LISTENING    19788

STEP — 2

taskkill /F /PID 19788
SUCCESS: The process with PID 19788 has been terminated.

Source

Have you ever encountered a situation where you needed to free up a port on your system but found it stubbornly held by a process? Whether you’re on Mac, Windows, or Linux, here’s a guide to gracefully handling this common issue.

Mac OS

Step 1: Find the Process ID (PID)

sudo lsof -i :portNumber

Enter fullscreen mode

Exit fullscreen mode

Replace portNumber with the actual port number. Copy the PID number.

Step 2: Kill the Process

kill PID

Enter fullscreen mode

Exit fullscreen mode

Replace PID with the copied process ID. If necessary, try kill -9 PID or sudo kill -9 PID for forceful termination.

Windows

Step 1: Find the Process ID (PID)

netstat -ano | findstr :portNumber

Enter fullscreen mode

Exit fullscreen mode

Replace portNumber with the port number. Copy the PID number.

Step 2: Kill the Process

taskkill /PID typeyourPIDhere /F

Enter fullscreen mode

Exit fullscreen mode

Replace typeyourPIDhere with the copied PID. Recheck using the first command.

Linux

Step 1: Get a List of All Open Processes

top

Enter fullscreen mode

Exit fullscreen mode

Step 2: Kill a Process

kill pid

Enter fullscreen mode

Exit fullscreen mode

Use killall pname to kill by name. Add -9 for forceful killing. Use sudo if needed.

Remember, terminating processes forcefully (-9) should be a last resort as it can cause data loss or system instability. Always try graceful termination (kill) first.

By following these steps tailored to your operating system, you can efficiently manage and free up ports, ensuring smooth operation for your applications. Whether you’re a developer, sysadmin, or simply a curious user, mastering these techniques can save you time and frustration.

For more blogs like this, visit www.adityarawas.in


For more blogs like this, visit www.adityarawas.in

Open ports in Windows 10 are often deemed dangerous because hackers can exploit them if the service or application the ports are associated with are unpatched or lack basic security protocols. Therefore, it is recommended to close any listening network ports that your system isn’t using.

Let us brief you on what ports are and why they can be dangerous.

Table of Contents

What are network ports?

Network ports are used by Windows services and applications to send and receive data over the network. If you wonder if this is what the IP address is used for, then you are absolutely correct. However, a unique IP address defines the path to a specific device, whereas a port defines what application or service on that particular device to send that information to.

Just like the IP addresses, a port is also unique within its ecosystem. Meaning, the same port cannot be used by two different services/applications. Therefore, both of these unique identifiers, the IP address, and the port number, are used to send and receive information from a computer.

A port number can be found suffixed to an IP address, as in the example below:

xxx.xxx.xxx.xxx:80

Here, the numbers followed by the colon denote the port number. Below are a few ports used by certain services and applications by default:

  • FTP – 21
  • SSH – 22
  • Telnet – 23
  • SMTP – 25
  • DNS – 53
  • DHCP – 67 & 68
  • HTTP – 80 & 8080
  • HTTPS – 443
  • SNMP – 161
  • RDP – 3389

A single IP address can have 65535 TCP and 65535 UDP ports in total.

Are open network ports dangerous?

Not all ports that are listening are dangerous. Sometimes an application opens the ports automatically without informing the users. If the application is poorly constructed and the security protocols lack the basic infrastructure, an attacker might exploit those and infiltrate your PC.

An open networking port is not always dangerous, but it is always better to keep your guard up and close any ports that are not required.

2 ways to check which ports are open/listening in Windows 10

You can figure out which ports are currently open on your computer, even if the installed applications did not inform you that they are using them. Here are 2 ways to check which ports are open and which service/application uses them on your local computer before you proceed to block them.

Here is a guide to check if a remote network port is open.

Determine open ports with process name using Command Prompt

Some applications give out the name of the application/service associated with a port number. You can use the below-given command in Command Prompt to determine which ports are open and what are the names of the associated applications.

  1. Open Command Prompt with administrative privileges.
  2. Enter the following command:
    netstat -ab
  3. Command Prompt will now display the output of open network ports with their associated application/service names, as in the image below:
    cmd 1 1

Since the IP address assigned to our computer is 10.0.0.31, it displays different ports used by various applications suffixed to the IP address. However, as you may notice, some of the names of the services and applications are unidentifiable. For that, we shall adopt the second method.

Determine open ports with process ID using Command Prompt

In this approach, we shall be comparing the process IDs of the running applications and services associated with the ports and then determining the name of the process using the Task Manager. Here is how to do so:

  1. Open Command Prompt with administrative privileges.
  2. Enter the following command:
    netstat -aon
  3. Command Prompt will now display a list of TCP and UDP ports currently listening on your computer. Note the associated PIDs to compare from the Task Manager.
    PID

  4. Now open the Task Manager by right-clicking on the Taskbar and clicking on Task Manager. Or, you may use the Ctrl + Shift + Esc shortcut keys.
  5. Now switch to the Details tab within the Task Manager and match the PID with the associated name of the process/application.
    task manager

Now you have sufficient information on the ports you would like to close, if any. Proceed to the next step to block/close any listening ports on your computer.

How to close an open port

If you have found a port that you are no longer using or are not sure if it is secure to keep open, you should preferably block it. If you wish to close an open port, you can do so with Windows Firewall  or Windows Defender in case of Windows 10.

  1. Open the Windows Firewall by going to Start –> Control Panel –> Windows Firewall. If you are using Windows 10, you can open the Windows Defender Firewall by going to Run –> firewall.cpl.
  2. From the left side menu, click on Advanced settings.
  3. From the right side menu of the new window, select Inbound Rules.
    New Rule

  4. Then click New rule in the right pane.
  5. On the Rule type screen in New inbound rule wizard, select Port and then click Next.
    port

  6. On the next screen, select the type of port as determined through the Command Prompt earlier, and then enter the port number you want to close in front of Specific local ports. Click Next when done.
    local port

  7. On the next screen, select Block the connection and then click Next.
  8. On the Profile screen, select All Profiles and click Next.
    profiles

  9. Now set a name for the rule and click Finish.

You have now successfully disabled the port. You can repeat the steps to block additional ports or delete this one by navigating to the Inbound rules and removing the respective rules.

How to quickly close ports using Command Prompt

A couple of commands can be used to identify the processes that have opened the ports and then close the ports by killing the process.

  1. Open Command Prompt and run the command: netstat -a -o -n. This will show all the open ports in your system along with their current state and the process ID that have opened the ports.
  2. If you want to find a specific port, you should run the command: netstat -a -o -n | findstr “993”. Replace 993 with the port number you want to find.
    Find open ports in cmd

  3. The last column on the list is the Process ID or PID number. Killing the process will automatically close the listening port. To kill the process, run the command: taskkill /pid 993.
    Kill the process to close ports

Please note that this is a quick and temporary way of closing the port using the command prompt. If you want to permanently block the port from opening again, you should follow the first method given above.

How to block network ports in Windows Firewall using Command Prompt

Block port in Windows Firewall using command line

You can also permanently block ports in Windows Defender Firewall using the Command Prompt.

To create a block port rule in Windows Firewall, run the following command in Command Prompt:

netsh advfirewall firewall add rule name="Rule Name" protocol=TCP dir=out remoteport=993 action=block

Replace Rule Name with your own rule name, for example, since I’m blocking IMAP port, I’ll name the rule as Block IMAP. Replace TCP with either RCP or UDP, whichever port you want to block. Replace 993 with the actual port number you want to block.

Unblock/Open port in Windows Firewall using command line

To open the port again, simply run the following command in CMD:

netsh advfirewall firewall delete rule name="Rule Name"

Replace Rule Name with the actual rule name, Block IMAP in my case. This will delete the rule that we created above.

Closing words

Listening ports are not always dangerous, as it is very much dependent on what application/service it is open through. Nonetheless, it is still important not to give the attacker any chance to exploit your system’s vulnerabilities and wise to close any ports that are not being used.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Lenovo yoga 11 windows rt восстановление
  • Эмулятор приложений windows для linux
  • Перенос системы на другой компьютер windows 10
  • Get windows key cmd
  • Lenovo energy management или lenovo utility for windows 10