1 2 3 Previous Next 36 Replies Latest reply on Jul 18, 2006 12:36 AM by mcalexy2k

    Connection refused to host: 127.0.0.1

      I am trying to connect to JBoss from a client but
      I get the exception below.
      I used the correct server address in jndi.properties
      java.naming.provider.url=xxx.xxx.xxx.xxx:1099

      What is wrong? Why 127.0.0.1 instead of xxx.xxx.xxx.xxx?

      Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
      java.net.ConnectException: Connection refused
      java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
      at java.net.Socket.(Socket.java:273)
      at java.net.Socket.(Socket.java:100)
      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:25)
      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:120)
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:365)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)

        • 1. 3819173
          rp6

           

          "crowley" wrote:
          "crowley" wrote:
          Perhaps you should try
          worker.ajp12.host=127.0.0.1


          • 2. Re: Connection refused to host: 127.0.0.1

            There is something wrong with your ip configuration.
            RMI thinks your server's ip address is 127.0.0.1

            You can check this by adding the following parameter
            to the java command in run.sh or run.bat

            (on the SERVER side !)

            -Djava.rmi.server.hostname

            RMI will now use the server's hostname instead of
            trying to determine the ip address.
            If this fixes your problem, then check you ip configuration.

            You might want to continue to use host names?

            Regards,
            Adrian

            • 3. Re: Connection refused to host: 127.0.0.1

               

              "adrian@jboss.org" wrote:
              "adrian@jboss.org" wrote:
              You can get similar problems on multi-homed servers.
              i.e. servers with multiple ip addresses.

              In this case always use
              -Djava.rmi.server.hostname

              Regards,
              Adrian


              • 4. Re: Connection refused to host: 127.0.0.1
                cpaul_it

                 

                "cpaul_it" wrote:
                "cpaul_it" wrote:
                The client having it's own jndi.properties still does not work.

                I have two ip addresses on the JBoss server machine (one is 10.0.0.17 and the other is external).

                On the client machine, which has only one ip address (10.0.0.51) I set the java.naming.provider.url to 10.0.0.17:1099. I know I am hitting the JBoss Server, because the java.rmi.ConnectIOException that is thrown indicates a failure trying to open a socket using the JBoss server's external ip address. The only way it could get the external address would be from the naming service running on the JBoss server.

                Any other ideas?


                • 5. Re: Connection refused to host: 127.0.0.1
                  cpaul_it

                   

                  "cpaul_it" wrote:
                  "cpaul_it" wrote:
                  As I continued to research, I eventually came back to this topic several times, and finally I realized that I had not picked up on the -Djava.rmi.server.hostname entry. So, as instructed, I set it to
                  -Djava.rmi.server.hostname=10.0.0.17 and it worked perfectly.

                  Thanks Adrian!

                  Paul


                  • 6. Re: Connection refused to host: 127.0.0.1
                    tobias

                     

                    "Tobias" wrote:
                    "Tobias" wrote:
                    On newer JBoss versions the error message may read:

                    javax.naming.CommunicationException. Root exception is
                    java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
                    nested exception is:
                    java.net.ConnectException: Connection refused: connect
                    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
                    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)


                    On the machine the JBoss server runs on check your /etc/hosts file. Only having an localhost entry there is not enough. You need an additional entry with your IP address and your host name of the server.

                    RedHat installations are known to have these problems :(.


                    • 7. Re: Connection refused to host: 127.0.0.1
                      tobias

                       

                      "Tobias" wrote:
                      "Tobias" wrote:
                      On newer versions of JBoss the error message may vary, one reads:

                      javax.naming.CommunicationException. Root exception is
                      java.rmi.ConnectException: Connection refused to host: 127.0.0.1;
                      nested exception is:
                      java.net.ConnectException: Connection refused: connect
                      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
                      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)


                      RedHat installations are known to have a wrong /etc/hosts file on the SERVER. You need to check the following on the SERVER.

                      The command "hostname" returns the used hostname, let's say it is "peterpan". /etc/hosts needs to look like this then:


                      10.0.0.1 peterpan
                      127.0.0.1 localhost.localdomain localhost


                      After that change "ping peterpan" should NOT ping to 127.0.0.1 but to the server IP address which was assumed to be 10.0.0.1 in the above example.

                      Restart the JBoss server now and try again.


                      • 8. Re: Connection refused to host: 127.0.0.1
                        tobias

                         

                        "Tobias" wrote:
                        "Tobias" wrote:
                        I'd like to ask people who are seeing this problem to tell us in this thread which of the proposed solutions worked for them.


                        • 9. Re: changing '/etc/hosts' solved the problem [Connection ref
                          kg1959

                           

                          "kg1959" wrote:
                          "kg1959" wrote:
                          Thanks for your valuable research work, fellows.

                          I took the solution to add an additional line in the /etc/hosts-file and now the clients run fine without the mentioned exception.

                          I hesitate to try out the -Djava=....-parameter-solution as the run.sh-script looks pretty complicated to me (newbie).

                          OS on my machine: RedHat-Linux 7.1

                          Thanks again !
                          Kurt


                          • 10. Re: Connection refused to host: 127.0.0.1
                            jonlee

                             

                            "jonlee" wrote:
                            "jonlee" wrote:
                            This is a known Sun Java RMI problem. Usually on Unices, the recommended solution is to ensure that the /etc/hosts is properly configured for resolution of the hostname.

                            However, this becomes a problem if you have DHCP on your primary interface. In this case, you may need to revert to using the -D:java.rmi.server.hostname=xxx.xxx.xxx.xxx type substitution or if you have a secondary interface, changing the hostname resolution in /etc/hosts to the secondary interface. You may have network-related side-effects with the latter.

                            If you must bind to the DHCP interface, you can put in some scripting substitutions to substitute the current assigned IP address. The problem will be that if the IP address changes during the lifetime of the server runtime instance, you will need to restart JBoss.

                            We've also had problems on Windows when dialled up to a client. If you start up JBoss when connected, the primary interface is the PPP. After disconnection, JBoss fails because the RMI interface was the PPP which has now gone - so you need to restart JBoss for things to work again.


                            • 11. Re: Connection refused to host: 127.0.0.1
                              whitemouse

                               

                              "whitemouse" wrote:
                              "whitemouse" wrote:
                              test


                              • 12. Re: Connection refused to host: 127.0.0.1
                                keith_elliott

                                 

                                "keith_elliott" wrote:
                                "keith_elliott" wrote:
                                I recently experienced a similar problem.

                                In my case, JNDI simply would hang - no errors, no response, just hang.

                                Ultimately, we realized we had our /etc/hosts file setup incorrectly - the IP for the server was invalid.

                                Here's the thread where I discuss it in more detail: http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=


                                • 13. Re: Connection refused to host: 127.0.0.1
                                  ryanho

                                   

                                  "ryanho" wrote:
                                  "ryanho" wrote:
                                  Both methods, i.e. editing run.sh JAVA_OPTS entry to add

                                  -Djava.rmi.server.hostname entry

                                  AND

                                  adding the IP address to the /etc/hosts

                                  Worked for me


                                  • 14. Re: Connection refused to host: 127.0.0.1
                                    buckman1

                                     

                                    "buckman1" wrote:
                                    "buckman1" wrote:
                                    I'd just like to add, if you are trying to cluster JBoss with a linux and windows machine, you'll want to also make sure to do this step. I found out the hard way with RedHat 9 that even though the JavaGroups multi-cast test worked, I was still not seeing the windows and linux nodes find each other.


                                    1 2 3 Previous Next