com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1; nested exception is: java.net.ConnectException: Connection refused: 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

,

Make sure your server started correctly and is listening correctly on the correct port.

,
Expert tip

Firewall might be blocking your connection, or MySQL it's not running on your server machine.

Solutions on the web

via blogspot.com by Unknown author, 1 year ago
Couldn't connect to host, port: localhost, 25; timeout -1; nested exception is: java.net.ConnectException: Connection refused: connect
via Stack Overflow by Nirmala Madusanka
, 8 months ago
Couldn't connect to host, port: smtp.gmail.com, 465; timeout -1; nested exception is: java.net.SocketException: Permission denied: connect
via Stack Overflow by Lampros Tzanetos
, 2 months ago
Couldn't connect to host, port: localhost, 25; timeout -1; nested exception is: java.net.ConnectException: Connection refused
via Stack Overflow by Sarpy
, 1 year ago
Couldn't connect to host, port: localhost, 25; timeout -1; nested exception is:
via Coderanch by Neha Sud, 8 months ago
Couldn't connect to host, port: 172.31.1.6:8090, 25; timeout -1; nested exception is: java.net.UnknownHostException: 172.31.1.6:8090
via journaldev.com by Unknown author, 1 year ago
Couldn’t connect to host, port: smtp.gmail.com, 587; timeout -1; nested exception is: java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: Connection refused: 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:301)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:229)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1950)
at javax.mail.Service.connect(Service.java:345)
at javax.mail.Service.connect(Service.java:226)
at javax.mail.Service.connect(Service.java:175)
at javax.mail.Transport.send0(Transport.java:253)
at javax.mail.Transport.send(Transport.java:124)
at undefined.Testing.main(Testing.java:62)

Users with the same issue

332 times, 55 minutes ago
39 times, 1 week ago
Once, 1 month ago
3 times, 1 month ago
91 times, 1 month ago

Write tip

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