Connection Refused Error Java/Linux

Dennis Röttger asked:

I’m trying to move an existing project over to a new (linux) server environment (note, I have no direct access to the code nor do I have any knowledge about the project in general – talk about a great start), upon starting the project I receive the following error:

Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: <servername>:1459 [Root exception is javax.naming.CommunicationException: Failed to connect to server <servername>:1459 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server <servername>:1459 [Root exception is java.net.ConnectException:     Connection refused]]]
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.jboss.Shutdown.main(Shutdown.java:214)
Caused by: javax.naming.CommunicationException: Failed to connect to server <servername> [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server <servername>:1459 [Root exception is java.net.ConnectException: Connection refused]]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
    at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
    ... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server <servername>:1459 [Root exception is java.net.ConnectException: Connection refused]
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
    ... 5 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:276)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
    at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
    at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
    ... 5 more

Now, I’ve opened the port in question to see whether there are any changes when I do so, alas, nothing happens.

I’m sorry about this very vague level of information, but it’s really all I have, I’ll gladly provide what I can if you have any ideas what could be at fault here.

Regards,

Dennis

My answer:


We see from your application exception that it is trying to connect to some server on port 1459, and that the reason for the failure is Connection refused.

This has two possible causes:

  1. Most likely: The remote service is not running. To resolve, start the remote service.
  2. Less likely: The remote service is firewalled. To resolve, open the firewall.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.