I got a same error: "java.net.ConnectException: Connection refused", when I did remote debugging my local web server from a Java applicaiton.
Finally I found the problems:
The URL in the property file in my Java application should be accessible and tested from the browser.
After made the above two changes, the issue resolved for me.