When using Tomcat in IntelliJ IDEA under mac system, an error occurs: Address localhost:80 is already in use
Error running ‘Tomcat 8.0.41’: Address localhost:80 is already in use
和
Error running ‘Tomcat 8.0.41-81’: Cannot run program “/Users/。。。/。。。/apache-tomcat-8.0.41/bin/catalina.sh” (in directory “/Users/。。。/I。。。/apache-tomcat-8.0.41/bin”): error=13, Permission denied
Table of contents
1. Situation description
When I use tomcat and write the port number as 80, it cannot be started immediately. The error message indicates that it is already in use. The error message is as follows: Error
running 'Tomcat 8.0.41-81': Address localhost:80 is already in use
When changing the port number to 8080, the error message "No permissions" is displayed. The error message is as follows:
Error running 'Tomcat 8.0.41-81': Cannot run program "/Users/.../.../apache-tomcat-8.0. 41/bin/catalina.sh” (in directory “/Users/…/I…/apache-tomcat-8.0.41/bin”): error=13, Permission denied
2: Draw conclusions after searching for information:
1. Mac prohibits ordinary users from accessing ports below 1024, including port 80.
2. When starting tomcat through eclipse, it can start normally and use port 80. However, when starting tomcat through IDEA, it will show that port 80 is occupied. 3. When
using ports 1024 and later, the error is reported because it is not given permission and needs to be opened.
Three: Solution
1: Ports below 1024 are occupied
You need to use root to open the idea to solve the problem. For specific methods, see Four
. Note: After solving problem 1, all your ports will become the error of problem 2. Once you run it, the error message of problem 2 will appear.
2: Ports 1024 and above have no permissions
Since the permissions are occupied, you need to open the permissions.
Open the terminal in the tomcat directory and execute it.
chmod -R 777 *
See five for detailed explanation
Four: How to open idea with root
Open the terminal and execute the code
sudo "/Applications/iTunes.app/Contents/MacOS/iTunes"
Finally click return which is Enter
Or open the terminal, enter sudo and a space, and then drag the last idea in. The same is true. Finally, click return, which is Enter. Click on the idea in the following picture to display the package content
.
Drag this idea into the terminal
Five: Detailed explanation of opening permissions
1: Select the Tomcat you are using and right-click "New terminal port located in the folder location"
2: Then enter in the terminal
chmod -R 777 *
Just run