zoukankan      html  css  js  c++  java
  • 利用netstat和tasklist查看PC的端口占用情况 及80端口被占用

      经常,我们在启动应用的时候发现系统需要的端口被别的程序占用,如何知道谁占有了我们需要的端口?

    1、Windows平台
    在windows命令行窗口下执行:

    E:oracleora92in>netstat -ano |find ":80"
    TCP 172.18.2.56:3311 172.18.40.3:80 ESTABLISHED 3704
    TCP 172.18.2.56:3319 172.18.65.7:80 ESTABLISHED 3704
    TCP 172.18.2.56:4641 172.18.40.3:80 ESTABLISHED 3704
    TCP 172.18.2.56:4734 172.18.65.7:80 ESTABLISHED 3704
    TCP 172.18.2.56:4847 172.18.40.3:80 ESTABLISHED 3560
    TCP 172.18.2.56:4848 172.18.40.3:80 ESTABLISHED 3560

    有个PID为3560的进程占用了80端口,继续执行下面命令:
    E:oracleora92in>tasklist /svc |find "3560"
    firefox.exe 3560 Console 0 147,564 K

    可以发现是firefox的进程,并可看到占用的内存大小。

    附netstat命令参数效果的对比:
    E:oracleora92in>netstat -a |find ":8080"
    TCP wanhua:8080 0.0.0.0:0 LISTENING

    E:oracleora92in>netstat -an |find ":8080"
    TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING

    E:oracleora92in>netstat -ano |find ":8080"
    TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING

    win7无法启动apache:

    最近在WIN7中安装XAMPP,无法启动apache,显示的log为: 

    20:41:12  [Apache] Error: Apache shutdown unexpectedly. 
    20:41:12  [Apache] This may be due to a blocked port, missing dependencies, 
    20:41:12  [Apache] improper privileges, a crash, or a shutdown by another method. 
    20:41:12  [Apache] Check the "/xampp/apache/logs/error.log" file 
    20:41:12  [Apache] and the Windows Event Viewer for more clues 

    通过运行apache/bin/httpd.exe 打印如下log: 
    (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : make_sock: could not bind to address 0.0.0.0:443 

    也就是443端口被占用,apache无法监听443端口,该如何解决呢? 

    最直接的方法是关闭占用443端口的进程: 
    1.通过cmd中打印tasklist,查找占用443端口的进程。 
    2.taskkill /pid 端口号 杀掉此进程,XAMPP重启apache即可。

  • 相关阅读:
    线性表——(2)单向链表
    线性表——(1)顺序表
    UVa 1592 数据库
    UVa 12096 集合栈计算机
    Python 协程
    Python 多线程及进程
    Python 日志(Log)
    Python 函数式编程
    Python基础
    DB2 获取前两天的数据
  • 原文地址:https://www.cnblogs.com/youxin/p/3381503.html
Copyright © 2011-2022 走看看