Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am unable to connect to any host through Java programs, getting

java.net.ConnectException: Connection refused.

Does it have anything to do with Ubuntu firewall configurations or any other setting? I am running Ubuntu 12.04 LTS

share|improve this question

1 Answer 1

Method1 First try to ping destination host , if host is ping-able it means client and server machine are in network.

Method2 Try connecting to server host and port using telnet. If you are able to connect means something is wrong with your client code. Also by observing telnet output you will come to know whether server is running or not or server is disconnecting the connection.

If you would like to know more about this error I mean why it is happening and how then please click the following


hope that helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.