Tomcat7 is listening port but not processes requests

19,705

Core problem was that tomcat listens to ipv6 tcp port. I tried to get to my page via ipv4 adress. So i created setenv.sh in /usr/share/tomcat7/bin with single line

JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true"

and restarted tomcat via

sudo bash tomcat7 restart

in /etc/init.d Then checked my port again with

netstat -na | grep -e 8080

and saw, that ipv4 is using now

tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN

And after few minutes i could get to my index.html

Thanx @Idaho06 for

netstat -na | grep -e 8080

I would never found problem without it

Share:
19,705

Related videos on Youtube

Asprelis
Author by

Asprelis

Updated on September 18, 2022

Comments

  • Asprelis
    Asprelis over 1 year

    Im trying to run my web server in VPS based on ubuntu 14.04. As i tried before on other systems i can check if my tomcat is fine, by going to _http://myIp:8080 and see "It works" index page, but not this time. And honestly im going crazy because i cant figure whats wrong.
    I installed tomcat just with command

     apt-get install tomcat7
    

    All was fine. I checked that port 8080 is open and went to _http://myIp:8080 - and nothing happens. I can't see 404 (that would mean that tomcat managed request) and I cant see "connection failed" (that would mean, that port is closed or thmthng). Connection is just hangs.

    I tried to change tomcat port to 1666 (of course, i turned off ufw firewall) Reloaded server, and ROOT deployment was fine again. But i still cant get anything from my server (answer or error) _http://myIp:1666

    Here is catalina start log.

    And there is nothing except deployment logs.

    I have reinstalled tomcat couple of times, but still no result.


    UPD


    i killed my old VPS and created new one. installed tomcat 7 via apt-get again so he is listening to 8080. and here is my grep result
    netstat -na | grep -e 1666 -e 8080
    tcp6       0      0 :::8080                 :::*                    LISTEN
    

    OMG doez it means that tomcat binds to ipV6 and i trying to get my page via ipV4?

    UPD2


    I created senenv.sh for tomcat with
    JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true"
    


    and now my tomcat listening to ipv4 tcp. But still no result. When i trying to connect myIP:8080 there is nothing happens/

    -na | grep -e 1666 -e 8080
    tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
    


    UPD3


    IT F***g works.
    I missed why, i just spend 10 more minutes in internet after restarting tomcat, trying to find something to solve my problem. And then i tried to get myIP:8080 again - and i saw "It works" index page.
    • Asprelis
      Asprelis over 9 years
      updated my question. I checked with ping.eu - this is good site for such sings
  • Lokomotywa
    Lokomotywa about 8 years
    i think it must be setenv.sh, not setenc.sh
  • Asprelis
    Asprelis about 8 years
    @ Ferenjito Thanx! Fixed.
  • Madhusoodan P
    Madhusoodan P almost 4 years
    @Asprelis can you please share why binding to ipv6 can be a problem? In my case a TCP connection is setup but server doesn't respond back. I would like to dig deeper.