louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
60.35k stars 5.4k forks source link

cannot connect to local SMTP #5225

Open sandsjh opened 1 month ago

sandsjh commented 1 month ago

⚠️ Please verify that this question has NOT been raised before.

🛡️ Security Policy

📝 Describe your problem

Howdy. I cannot connect to my local SMTP when using docker image. I have also tried using the public IP and FQDN to no avail. I stood up a server on Amazon to get around the issue for now. Using iptables and Digital Ocean firewall. The only limitations in place are US only in which the docker is in US.

📝 Error Message(s) or Log

No response

🐻 Uptime-Kuma Version

1.23.15

💻 Operating System and Arch

Debian Bookworm X64

🌐 Browser

shows auto?

🖥️ Deployment Environment

CommanderStorm commented 1 month ago

What docker network using? https://docs.docker.com/engine/network/

sandsjh commented 1 month ago

What docker network using? https://docs.docker.com/engine/network/

Default docker install and default Uptime Kuma install.

sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc

sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
leelaprasadv commented 1 month ago

Hey @sandsjh, Could you please provide the exact error message you’re encountering? I was able to successfully connect Uptime Kuma with MailDev (a local SMTP server for testing).

Could you also clarify

From your description, it seems that since the SMTP server is local, you might be using localhost as the hostname. Are you seeing a getaddrinfo ENOTFOUND localhost error when testing the connection?

Please note that when you specify “localhost” in Uptime Kuma, it refers to the same Docker container (Uptime Kuma itself) as it refers to the loopback address, not the host machine’s address.

You can resolve this by adjusting the hostname as follows:

For windows/Mac with Docker desktop: Simply change the hostname to host.docker.internal

For linux: You’ll need to add the --add-host flag to the Uptime Kuma container’s run command as shown below:

docker run -d --restart=always --add-host=host.docker.internal:host-gateway -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1.23.15

Uptime Kuma SMTP config: image

Test Email on MailDev image

More details here Hope this helps!