Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot send notification using smtp: timed out #1970

Closed
Riftr opened this issue Apr 30, 2024 · 3 comments
Closed

Cannot send notification using smtp: timed out #1970

Riftr opened this issue Apr 30, 2024 · 3 comments

Comments

@Riftr
Copy link

Riftr commented Apr 30, 2024

Describe the bug

Cannot send notifications using Google's SMTP service.

Steps to reproduce

  1. Configure watchtower using docker-compose as per https://containrrr.dev/watchtower/notifications/
version: "3.8"
services:
  watchtower:
    container_name: watchtower
    image: containrrr/watchtower 
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped
    environment:
      WATCHTOWER_NOTIFICATIONS: email 
      WATCHTOWER_NOTIFICATION_EMAIL_FROM: myuser@domain.com
      WATCHTOWER_NOTIFICATION_EMAIL_TO: me@domain.com
      WATCHTOWER_NOTIFICATION_EMAIL_SERVER: smtp.gmail.com
      WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT: 587
      WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER: myuser@domain.com
      WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD: app password
      WATCHTOWER_NOTIFICATION_EMAIL_DELAY: 2

  1. docker-compose up
  2. Receive the following error:

`watchtower | time="2024-04-30T03:54:12Z" level=error msg="Failed to send shoutrrr notification" error="failed to send using smtp: timed out" index=0 notify=no service=smtp``

Can access smtp.gmail.com just fine:

$ ping smtp.gmail.com
PING smtp.gmail.com (142.251.10.108) 56(84) bytes of data.
64 bytes from sd-in-f108.1e100.net (142.251.10.108): icmp_seq=1 ttl=56 time=107 ms
64 bytes from sd-in-f108.1e100.net (142.251.10.108): icmp_seq=2 ttl=56 time=107 ms
64 bytes from sd-in-f108.1e100.net (142.251.10.108): icmp_seq=3 ttl=56 time=108 ms

$ telnet smtp.gmail.com 587
Trying 74.125.68.108...
Connected to smtp.gmail.com.
Escape character is '^]'.

No email notifications are ever received.

Expected behavior

Receive email notifications via Gmail's SMTP server.

Screenshots

No response

Environment

  • Platform: Debian GNU/Linux 12 (bookworm)
  • Architecture: 64 bit
  • Docker Version: 20.10.24+dfsg1, build 297e128

Your logs

watchtower    | time="2024-04-30T04:06:22Z" level=debug msg="Sleeping for a second to ensure the docker api client has been properly initialized."
watchtower    | time="2024-04-30T04:06:23Z" level=debug msg="Making sure everything is sane before starting"
watchtower    | time="2024-04-30T04:06:23Z" level=debug msg="Retrieving running containers"
watchtower    | time="2024-04-30T04:06:23Z" level=debug msg="There are no additional watchtower containers"
watchtower    | time="2024-04-30T04:06:23Z" level=debug msg="Watchtower HTTP API skipped."
watchtower    | time="2024-04-30T04:06:23Z" level=info msg="Watchtower 1.7.1"
watchtower    | time="2024-04-30T04:06:23Z" level=info msg="Using notifications: smtp"
watchtower    | time="2024-04-30T04:06:23Z" level=info msg="Checking all containers (except explicitly disabled with label)"
watchtower    | time="2024-04-30T04:06:23Z" level=info msg="Scheduling first run: 2024-05-01 04:06:23 +0000 UTC"
watchtower    | time="2024-04-30T04:06:23Z" level=info msg="Note that the first check will be performed in 23 hours, 59 minutes, 59 seconds"
watchtower    | time="2024-04-30T04:06:35Z" level=error msg="Failed to send shoutrrr notification" error="failed to send using smtp: timed out" index=0 notify=no service=smtp

Additional context

No response

Copy link

Hi there! 👋🏼 As you're new to this repo, we'd like to suggest that you read our code of conduct as well as our contribution guidelines. Thanks a bunch for opening your first issue! 🙏

@Riftr
Copy link
Author

Riftr commented Apr 30, 2024

The problem was on Docker's end, when using a bridge the DNS server gets set to 127.0.0.11 for the watchtower container by default and for some reason this wasn't resolving smtp.gmail.com correctly even though the host could.

Explicitly binding the ports for my local DNS server (also hosted in a docker container) to the local network address allows the Watchtower container to correctly look up smtp.gmail.com.

In DNS server's docker-compose.yml:

    ports:
      - "192.168.1.225:53:53/tcp"
      - "192.168.1.225:53:53/udp

I imagine setting extra_hosts: in the Watchtower docker-compose.yml file would have likely also resolved it too by hardcoding the DNS entry but I didn't end up needing to try that in the end.

@Riftr
Copy link
Author

Riftr commented Apr 30, 2024

It's always DNS.

@Riftr Riftr closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant