"Connection refused" means that the host at the specified IP address was successfully reached but that no service was registered to listen on the port number that you specified.1

So there are really only a very few reasons that you could get that error:

Looking at "netstat -a" on the service's host (if it is running Unix or Windows, at least) would tell you what ports are being listened to for which addresses. If you are on Unix, then you can use "sudo netstat -ap" to even see which process is listening on each port (on Windows you would use "netstat -ab" in a cmd prompt with elevated privileges).

See also connect. The entry for ECONNREFUSED is quite short there but is accurate and would have been a very good clue.

1 Or, quite rarely, it can be that a TCP service is listening on that port number and is not using the 'socket' library (which is, by far, the most commonly used library) to accept requests at that port number. In such a case, it is possible for the service to examine information in the first part of the TCP handshake (usually the source IP address, that is, the client's IP address) and reject the request in the same way that the TCP stack will reject a request for an unlistened to port number.

- tye        


In reply to Re: Error in HTTPS connection with error: No connection could be made because the target machine actively refused it. at C:/Perl/lib/LWP/Protocol/http.pm line 47 (ECONNREFUSED) by tye
in thread Error in HTTPS connection with error: No connection could be made because the target machine actively refused it. at C:/Perl/lib/LWP/Protocol/http.pm line 47 by jliu5

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.