Lsof -i: port number (my port number is 8020, so I enter the following command)
lsof -i:8020
After entering, you can see that the process id corresponding to the port is xxx, for example, mine is 1472, so the process of kill can. Enter the following command directly.
Kill 1472
Reference: mac failed to start springboot, port 8080 was occupied, and the mac command line closed port/blog/web/201805251638.