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

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
Expert tip

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.

,
Expert tip

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.

Solutions on the web

via Stack Overflow by Aryak Pande
, 1 year ago
Could not connect to SMTP host: smtp.gmail.com, port: 465; nested exception is: java.net.SocketException: Broken pipe
via Coderanch by Jawed Nazar Ali, 1 year ago
Could not connect to SMTP host: mail.sdfpak.org, port: 25; nested exception is: java.net.ConnectException: Connection refused
via Coderanch by ravi v kumar, 1 year ago
Could not connect to SMTP host: 10.45.26.62, port: 25; nested exception is: java.net.SocketException: Software caused connection abort: connect
via Coderanch by Mannu Pal, 1 year ago
Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
via Google Groups by Damian Marinaccio, 5 months ago
Unknown SMTP host: smtp.niper.ac.in; nested exception is: java.net.UnknownHostException: smtp.niper.ac.in
via Oracle Community by 843830, 6 months ago
Could not connect to SMTP host: smtp.mail.yahoo.com.sg, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect
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)

Users with the same issue

3 times, 10 hours ago
4 times, 15 hours ago
335 times, 16 hours ago
39 times, 1 week ago
Once, 1 month ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.