Search code examples
jettyremote-debuggingtcp

Jetty remote debug listens on 0.0.0.0?


I was trying remote debug a webapp. Follows the instruction on this jetty document . I got java process like this.

jetty     9682  0.4  2.2 4433620 87568 ?       Sl   15:52   0:03 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-0.b17.el6_7.x86_64/jre/bin/java -Xdebug -agentlib:jdwp=transport=dt_socket,address=12000,server=y,suspend=n -Djava.io.tmpdir=/tmp -Djetty.home=/opt/jetty -Djetty.base=/opt/jetty

But the process only listens on 0.0.0.0.

Here is the output of netstat -an

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:12000               0.0.0.0:*                   LISTEN 

So i can't connect this port on other IP.

My questions how this happen and how to fix it?

EDIT: I was wrong. I was confused by the output of netstat. Because the output of port 8080 is

tcp        0      0 :::8080                     :::*                        LISTEN 

I finally realized this may caused by the firewall. I solved the problem by add this port to iptables.


Solution

  • 0.0.0.0 means "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.

    From: https://en.wikipedia.org/wiki/0.0.0.0

    More info at Is binding to 0.0.0.0 in Java guaranteed to bind to all network interfaces?