java.rmi.ConnectException: Connection refused to host: 127.0.1.1;

前端 未结 14 2579
攒了一身酷
攒了一身酷 2020-11-27 15:08
    java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:
    java.net.ConnectException: Connection refused
    at sun.rmi.transport         


        
相关标签:
14条回答
  • 2020-11-27 15:22

    I had the same exact problem and my issue was that I had 2 IP addresses from 2 different networks configured in the etc/hosts as below.

    10.xxx.x.xxx    localhost
    192.xxx.x.xxx   localhost
    

    This should be because there was a conflict as to which IP to be used for the other devices to reach the rmiregistry over the network.

    Once I removed the extra-record that is not required, I was able to solve the issue.

    So my etc/hosts file had only the following record.

    10.xxx.x.xxx    localhost
    
    0 讨论(0)
  • 2020-11-27 15:22

    It works for me after getting rid of "::1" in /etc/hosts.

    0 讨论(0)
  • 2020-11-27 15:23

    This is item A.1 in the RMI FAQ. You need to either fix your /etc/hosts file or set the java.rmi.server.hostname property at the server.

    0 讨论(0)
  • 2020-11-27 15:23

    I found many of the Q&A on this topic, not nothing was helping me - that's because my issue was more basic ( what can I say I am not a networking guru :) ). My ip address in /etc/hosts was incorrect. What I had tried included the following for CATALINA_OPTS:

    CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true -Xmx128M -server 
    -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.port=7091 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false
    -Djava.rmi.server.hostname=A.B.C.D"  #howeverI put the wrong ip here!
    
    export CATALINA_OPTS
    

    My problem was that I had changed my ip address many months ago, but never updated my /etc/hosts file. it seems that by default the jconsole uses the hostname -i ip address in some fashion even though I was viewing local processes. The best solution was to simply change the /etc/hosts file.

    The other solution which can work is to get your correct ip address from /sbin/ifconfig and use that ip address when specifying the ip address in, for example, a catalina.sh script:

    -Djava.rmi.server.hostname=A.B.C.D
    
    0 讨论(0)
  • 2020-11-27 15:28

    Maybe your rmiregistry not be created before client trying connect to your server and it would lead to this exception.In Linux, you can use "netstat" to check your rmiregistry be bond on the right port you assigned in java code.

    0 讨论(0)
  • 2020-11-27 15:28

    If you've tried modifying etc/hosts and adding java.rmi.server.hostname property as well but still registry is being bind to 127.0.0.1

    the issue for me was resolved after explicitly setting System property through code though the same property wasn't picked from jvm args

    0 讨论(0)
提交回复
热议问题