How can I kill whatever process is using port 8080 so that I can vagrant up?

后端 未结 11 1706
鱼传尺愫
鱼传尺愫 2020-12-07 07:13

On MacOSX, I\'m using Packer to build a Vagrant box so I need to continually bring it up and tear it down. I\'m attempting to \'vagrant up\', and receive the standard error

相关标签:
11条回答
  • 2020-12-07 07:45

    This might help

    lsof -n -i4TCP:8080 
    

    The PID is the second field in the output.

    Or try:

    lsof -i -P
    
    0 讨论(0)
  • 2020-12-07 07:45

    I needed to run this command

    sudo lsof -i :80 # checks port 8080
    

    Then i got

    COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    acwebseca 312 root   36u  IPv4 0x34ae935da20560c1      0t0  TCP 192.168.1.3:50585->104.25.53.12:http (ESTABLISHED)
    

    show which service is using the PID

    ps -ef 312
    

    Then I got this

      UID   PID  PPID   C STIME   TTY           TIME CMD
        0   312    58   0  9:32PM ??         0:02.70 /opt/cisco/anyconnect/bin/acwebsecagent -console
    

    To uninstall cisco web security agent run

    sudo /opt/cisco/anyconnect/bin/websecurity_uninstall.sh
    

    credits to: http://tobyaw.livejournal.com/315396.html

    0 讨论(0)
  • 2020-12-07 07:47

    try netstat

    netstat -vanp tcp | grep 3000
    

    if your netstat doesn't support -p , use lsof

    sudo lsof -i tcp:3000 
    

    For Centos 7 use

    netstat -vanp --tcp | grep 3000
    
    0 讨论(0)
  • 2020-12-07 07:54

    Run: nmap -p 8080 localhost (Install nmap with MacPorts or Homebrew if you don't have it on your system yet)

    Nmap scan report for localhost (127.0.0.1)

    Host is up (0.00034s latency).

    Other addresses for localhost (not scanned): ::1

    PORT STATE SERVICE

    8080/tcp open http-proxy

    Run: ps -ef | grep http-proxy

    UID PID PPID C STIME TTY TIME CMD

    640 99335 88310 0 12:26pm ttys002 0:00.01 grep http-proxy"

    Run: ps -ef 640 (replace 501 with your UID)

    /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/XPCServices/com.apple.PerformanceAnalysis.animationperfd.xpc/Contents/MacOS/com.apple.PerformanceAnalysis.animationperfd

    Port 8080 on mac osx is used by something installed with XCode SDK

    0 讨论(0)
  • 2020-12-07 07:55

    To script this:

    pid=$(lsof -ti tcp:8080)
    if [[ $pid ]]; then
      kill -9 $pid
    fi
    

    The -t argument makes the output of lsof "terse" which means that it only returns the PID.

    0 讨论(0)
  • 2020-12-07 07:58

    You can also use the Activity Monitor to identify and quit the process using the port.

    0 讨论(0)
提交回复
热议问题