Is there a condition or state that Postfix can enter that will prevent connectivity on port 25?

Am using Javamail to send to postfix as the local MTA, which works about 99% of the time. However, I will occassionally see an exception like:

javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
    java.net.ConnectException: Connection refused

So, is it possible one of the queues is filling up and causing this? Is there a state Postfix could be in that will actively refuse a local connection?

Thanks in advance!

  • 2
    Anything in the postfix logs? – cjc Mar 29 '12 at 13:22
  • Have you tried turning it off and on? – qweet Mar 29 '12 at 13:27
  • Could you explain slightly more what your program is doing? If you're trying to send thousands of emails programmatically, it is possible you're flooding postfix with too many connection requests? More info generally would help. – webtoe Mar 29 '12 at 13:29
  • Yuo need to show the postfix logs pertaining to this issue. – adaptr Mar 29 '12 at 15:06
  • Going to get access to the logs. It is on a system where the log location has been restricted, so I need to get access via someone else. – Ode Mar 30 '12 at 13:29

If the connection is refused you need to check the logs to find out why.

If it works 99% of the time, then it's not a firewall issue. Postfix should be able to handle most loads without dying on you...if this is intermittently showing up in the logs, then it seems to be recovering. I'd look at the timestamp on the failed connection and match it to your logs in Postfix and see what happens around that time.


Connection refused usually means that the service is not listening on that port. In your case postfix was not running when you have seen that exception.

If postfix is to slow you will receive a timeout exception.

When an application is slow and is listening, the TCP connection will be established by the TCP subsystem, the kernel will dispatch the request to the application. The client will wait for the server answer until a timeout will occur (timeout that is configured in the application).

  • It means you received a TCP RESET packet. The OS will send one of those if the server is not listening on that port but there are other reasons they can be sent, such as TCP errors and firewall rules. – Ladadadada Mar 29 '12 at 13:33
  • I know. But, if nothing was changed at the network level, then the application is not listening. It could be also ICMP port unreachable or ICMP destination host unreachable. – Mircea Vutcovici Mar 29 '12 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.