Tomcat startup, 8080 address already in use

泄露秘密 提交于 2019-12-02 17:31:45
user1968048

I also had the same issue. Tried all the options suggested in this thread. But didnt help. Then just did ran:

ps -awwef | grep tomcat

and found some stale process running. I killed it using (-15 instead of -9)

sudo kill -15 <tomcat pid from previous command>

And woot! it worked. Restarted tomcat without any issue.

NEVER kill a process with signal -9, because this type of killing process leaves its resources present in the system, which can only be removed after a server reboot. only use kill -9 only in extreme emergency. better to use kill -15, as it might take some time to cleanup resources, but you would always get proper flushing of that whole set of resources, that the process is consuming. so most probably, the tomcat is not working as it has left some of the resources left in the memory. So, either perform a reboot or try to find following:

  • through lsof command and grep it with tomcat. it will show you anything that has tomcat associated with it

lsof | grep tomcat

  • search of any pid lock file on filesystem, left by tomcat.
  • Also try to issue:

lsof -i TCP | grep 8080

The port number is configured in $TOMCAT_HOME/conf/server.xml

If port 8080 is in use, change it in the server.xml file. Mine looks like this in server.xml

<Connector port="8085" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

Just running a lsof may be not enough. I suggest this command:

sudo lsof -i :8080

And then you can kill whatever process is holding the port (most probably another instance of tomcat).

Just for the record: I got this error (as a newbie) because I started Apache before starting Tomcat.

If I stopped Apache, then started Tomcat and then started Apache, the errors disappeared.

After entering the netstat -aon find the PID for 8080 port. Then go to task manager and find the Image Name for the PID in processes tab. right click on the Image Name and click on end process. Now if you start the server it will work.

I have also ran into this problem, but in my case, I have updated my application in my server from application in my local source. I have searched running tomcat instances with different methods like shown above and killed all of them followed by running it several times, but no use.

The reason why tomcat not properly shutting down or starting up was JDK version of the application source: I have built it with JDK 1.8, but in my server there was 1.7. After rebuilding my application with JDK 1.7 I had it working in both local and server machines. Hope, this information also helps someone like me.

Sometimes servlets must do a substantial amount of work to shut down, and as a result, tomcat may take some time to shutdown as well. If you wait a short bit before restarting the server, you may see the problem go away. If not, then it is possible a web application may not be responding to termination signals from the JVM, in which case tomcat may not correctly shut down.

Long story short, try adding a sleep to your restart script, or simply wait a short bit before calling start again.

The problem is tomcat may not properly shut down. try adding a sleep to your restart script, or simply wait a short mint before start tomcat again.

ps -awwef | grep tomcat

worked for me

found some stale process running. I killed it using (-15 instead of -9)

The best solution is stop running tomcat instance using the following command:

kill $(ps -aef | grep java | grep apache-tomcat-7.0.47 | awk '{print $2}')

Change 7.0.47 with your tomcat version. It works fine and the port number, i.e., 8080, will be released soon.

Navin Prakash Das

I was facing similar issue and found that 8080 port was being used for some other application . use netstat commnad on windows and see all the ports in use.

change the connector port in server.xml file . you can find this file in your tomcat installation directory under conf folder. open this file ,mine looked as below:

<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

change the port value to some other port preferably in the 80 series. hope it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!