Connection refused: connect

Apache's JIRA Issue Tracker | Kevin Lester | 7 years ago
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    An incorrect error message is being returned from the email class when a message fails to send due to a blocked port and SSL is specified. Specificaly, the port number in the error message is incorrect; it will show the stmp port that is set on the object (normally 25), when it should be showing the port that was set in the session when the session was created [465 when SSL is used]. This issue is only visible to the user if the email fails to send because the SSL port is blocked. The following code reproduces the issue: public void testErrorMessage(){ HtmlEmail email = new HtmlEmail(); try { email.addTo(""); email.setSubject("Testing Apache Error message "); email.setFrom(""); email.setMsg("Sending through gmail"); email.setSSL(true); email.setHostName(""); email.send(); } catch (EmailException e) { e.printStackTrace(); } } If port 465 is blocked, then you wil ge the following stacktrace: org.apache.commons.mail.EmailException: Sending the email to the following server failed : at org.apache.commons.mail.Email.sendMimeMessage( at org.apache.commons.mail.Email.send( at EmailTester.testErrorMessage( at EmailTester.main( Caused by: javax.mail.MessagingException: Could not connect to SMTP host:, port: 465; nested exception is: Connection refused: connect at com.sun.mail.smtp.SMTPTransport.openServer( at com.sun.mail.smtp.SMTPTransport.protocolConnect( at javax.mail.Service.connect( ... Note that the port is listed correctly in the inner exception, but it is incorrect in the topmost exception. I have fixed this issue in my sandbox, and will attach the patch to this issue.

    Apache's JIRA Issue Tracker | 7 years ago | Kevin Lester Connection refused: connect
  2. 0

    Can't connect to Hotmail with JavaMail

    Stack Overflow | 5 years ago Connection refused: connect
  3. 0

    Marco Tello » Configuring Oracle SOA Suite UMS Adapter with a gmail account | 10 months ago Connection refused: connect
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Configuring Java Mail Session | | 2 years ago Connection refused: connect
  6. 0

    Sending Emails in Java using GMail ID. Email in Java using GMail | 8 months ago Connection refused: connect

  1. bpbhat77 3 times, last 11 months ago
2 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis


    Connection refused: connect

    at com.sun.mail.smtp.SMTPTransport.openServer()
  2. JavaMail API (compat)
    1. com.sun.mail.smtp.SMTPTransport.openServer(
    2. com.sun.mail.smtp.SMTPTransport.protocolConnect(
    2 frames
  3. JavaMail API
    1. javax.mail.Service.connect(
    1 frame