Question: For some weird reason I am not able to connect using `VisualVM` or `jconsole` to a JMX.

The parameters used to start the VM to be monitored:

```
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=1100

```

I checked, and I can telnet to this port, from both locally and remotely.

Still, VisualVM or jconsole are failing to connect, after spending some considerably time trying to.

```
REMOTE MACHINE with JMX (debian)
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)

MY WORKSTATION (OS X)
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

```

What is the problem?

Answer: 
I had a similar issue when using port forwarding.
I have a remote machine with Tomcat listening for JMX interactions on `localhost:9000`.

From my local machine, I'm used to do port-forwarding with: 

```
ssh -L 9001:localhost:9000 tomcat.example.com

```

(so remote port 9000 is forwarded to my local machine's port 9001).

Then when I tried to use VisualVM to connect to `localhost:9001`, the connection was refused. JMX seems to require port numbers on both sides to be identical. 

So my solution was using port numbers 9000 and 9000:

```
    ssh -L 9000:localhost:9000 tomcat.example.com

```

Now my local machine's VisualVM connects successfully to the remote machine's Tomcat via `localhost:9000`.

Make sure that you don't have any other service (Tomcat on dev machine?) listening on the same port.

Also take a look at [setting up parameters correctly](https://stackoverflow.com/a/32418821/923560).
look in /etc/hosts if you don't have a wrong IP for your machine
example :
127.0.0.1 localhost
127.0.0.2 your\_machine
185.12.58.2 your\_machine (the good IP for your machine)

JMX take the IP 127.0.0.2 and forget the other