Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

    java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is:     java.net.ConnectException: Connection refused     at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)     at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)     at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)     at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:128)     at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)     at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)     at com.sun.proxy.$Proxy0.notifyMe(Unknown Source)     at CallbackServerImpl.doCallback(CallbackServerImpl.java:149)     at CallbackServerImpl.registerForCallback(CallbackServerImpl.java:70)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:601)     at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)     at sun.rmi.transport.Transport$1.run(Transport.java:177)     at sun.rmi.transport.Transport$1.run(Transport.java:174)     at java.security.AccessController.doPrivileged(Native Method)     at sun.rmi.transport.Transport.serviceCall(Transport.java:173)     at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)     at java.lang.Thread.run(Thread.java:722)     Caused by: java.net.ConnectException: Connection refused     at java.net.PlainSocketImpl.socketConnect(Native Method)     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)     at java.net.Socket.connect(Socket.java:579)     at java.net.Socket.connect(Socket.java:528)     at java.net.Socket.<init>(Socket.java:425)     at java.net.Socket.<init>(Socket.java:208)     at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)     at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)     at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)     ... 23 more 

I get this exception when I try to connect a remote client to my server. In both, server and client the hostName for the registryUrl of rmi is the public IP address of the server. I also tried to put localhost in server but the error doesn't change.

My java.policy is set to grant all connections to all ports and I have no firewalls enabled in the server or the client.

Any suggestions what could be?

like image 748
heythatsmekri Avatar asked Mar 28 '13 15:03

heythatsmekri


People also ask

How do I fix java net ConnectException Connection refused connect in java?

net. ConnectException: Connection refused: 1) First try to ping the destination host, if the host is ping-able it means the client and server machine are in the network. 2) Try connecting to server host and port using telnet.

How do I set the hostname for Java RMI server?

java.rmi.server.useLocalHostname rmi. server. hostname property is not specified and a fully qualified domain name for the localhost cannot be obtained. In order to force Java RMI to use the fully qualified domain name by default, you need to set the this property to true .

What does java net ConnectException Connection refused mean?

Connection refused is a clear case of a client trying to connect on a TCP port but not able to succeed. Below are some of the possible reason why java.net.ConnectException: Connection refused comes: 1) Client and Server, either or both of them are not in the network. 2) Server is not running.

How do I start an RMI registry?

To start the registry on the server, execute the rmiregistry command. This command produces no output and is typically run in the background. For this example, the registry is started on the host mycomputer . By default, the registry runs on port 1099.


1 Answers

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.

like image 68
user207421 Avatar answered Oct 23 '22 23:10

user207421