Search code examples
dockermailhog

Operation timed out when connecting to Mailhog in Docker container


I started mailhog in container: docker run --rm -ti -p 8025:8025 -p 1025:1025 mailhog/mailhog. Web UI works, but connection fails:

curl smtp://172.17.0.2:1025 --mail-from [email protected] --mail-rcpt [email protected]

curl: (28) Failed to connect to 172.17.0.2 port 1025 after 31641 ms: Operation timed out

172.17.0.2 is container IP address, i'm using Docker Desktop for Mac. Why connection is not established?


Solution

  • I solved this problem by connecting mailhog container to a network defined in docker-compose.yml.