javax.mail.MessagingException

Could not connect to SMTP host: smtp.gmail.com, port: 586; nested exception is: java.net.ConnectException: Connection timed out: connect

Samebug tips9

Check if your server (or a proxy server) is not going up and down. There might be something between a proxy and a client sending intermittent requests to non-functioning hosts as well. There might as well be too many requests in a short amount of time.

Check if ip adress is correct, if the port is correct, and if the server is up and running and waiting for connections. Also, check if there's no firewall blocking you and if your internet connection is working.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web784

  • via howtodoinjava.com by Unknown author, 9 months ago
    Could not connect to SMTP host: smtp.gmail.com, port: 586; nested exception is: java.net.ConnectException: Connection timed out: connect
  • Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out (Connection timed out)
  • Could not connect to SMTP host: smtp.gmail.com, port: 465; nested exception is: java.net.ConnectException: Connection timed out: connect
  • Stack trace

    • javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 586; nested exception is: java.net.ConnectException: Connection timed out: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1706) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:525) at javax.mail.Service.connect(Service.java:291) at javax.mail.Service.connect(Service.java:172) at demo.Emailsend2.sendEmail(Emailsend2.java:74) at demo.Emailsend2.main(Emailsend2.java:27) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at java.net.Socket.connect(Socket.java:528) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:284) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:227) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1672)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Unknown user
    Once, 11 months ago
    Unknown user
    Once, 1 year ago
    Once, 4 hours ago
    2 times, 3 weeks ago
    17 times, 1 month ago
    983 more bugmates