I spent HOURS trying to debug "Connection Refused" and "Connection closed by foreign host" errors when trying to use telnet to troubleshoot my connection. I was also trying to connect from my email client (macOS mail) around the same time. Telnet had also worked earlier, so I was extremely confused as to why it suddenly stopped working. I stumbled upon fail2ban.log in my container. In short, when trying to get my macOS client working, I exceeded the number of failed login attempts and fail2ban put dovecot and postfix in jail! I got around it by whitelisting my ipaddresses (my ec2 instance and my local computer)
```bash
sudo su
docker exec -ti mail bash
cd /var/log
cat fail2ban.log | grep dovecot
# Whitelist ip addresses:
fail2ban-client set dovecot addignoreip 172.18.0.1
fail2ban-client set dovecot addignoreip 75.171.128.95
fail2ban-client set postfix addignoreip 75.171.128.95
fail2ban-client set postfix addignoreip 172.18.0.1