• 利用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即可。

  • 相关阅读:
    Array
    java 设计模式
    Hashtable
    lettCode-Array
    最短路径 dijkstra
    算法:优先级队列
    7.29 DFS总结
    SZU:D89 The Settlers of Catan
    SZU:B47 Big Integer I
    7.25 RPN转换
  • 原文地址:https://www.cnblogs.com/youxin/p/3381503.html
Copyright © 2020-2023  润新知