meichthys / uptime_kuma

Uptime Kuma HACS integration
110 stars 23 forks source link

About “Failed to connect“... #47

Closed EvanVV closed 1 year ago

EvanVV commented 1 year ago

A few days ago, I deployed the Uptime-kuma docker project on Synology NAS, then resolved my domain name up.domain.com to the AmazonCloudServer, and deployed NginxProxyManager on the server to forward this domain name to a port on my home OpenWrt router by forwarding it to another domain name. Then I set up port forwarding on the router to the Uptime-kuma port on Synology NAS.

up.domain.com--->AmazonCLoudServer(NginxProxyManager,Forward to rt.domain.com:port,with Websocket Suport & SSL)--->OpenWrt(rt.domain.com:port)--->Port Forward to Synology NAS(Uptime-Kuma Service Port)

After everything was configured, I found that when I added my Uptime-Kuma in HomeAssistant, I was prompted with "Failed to connect", or "Unexpected error". So I changed my strategy to directly fill in NAS‘s internal IP and Uptime-Kuma service port when integrating in HomeAssistant, but still prompted "Failed to connect". Later, I tried to disable user authentication in Uptime-kuma and then go to HomeAssistant for integration, and it worked this time.

However, disabling user authentication means that my Uptime-kuma service is exposed to the public network without any reservation, which is a risk.

How can I integrate Uptime-kuma into HomeAssistant with user authentication enabled?

meichthys commented 1 year ago

I think we will need some logs here to help identify the problem since authentication is working fine on my end. Well want to look for relevant logs on the nginx machine and on the uptime kuma machine.

meichthys commented 1 year ago

@EvanVV Are you using API Keys? If so, it won't work currently since adding API keys to UptimeKuma will disable basic authentication which this integration relies on.

krakowski commented 1 year ago

I am experiencing the same issue. Even using the internal (private) ip inside my home network results in Failed to connect. The only log message I get inside Home Assistant is the following.

2023-05-03 15:12:12.454 ERROR (MainThread) [custom_components.uptime_kuma] Request exception for '<MY_INTERNAL_IP>:3001/metrics' with - <MY_INTERNAL_IP>:3001/metrics

Verify SSL certificate is unchecked during config flow.

I use Uptime Kuma version 1.21.2 without API Keys and without 2FA. Querying <MY_INTERNAL_IP>:3001/metrics seems to work without basic authentication (and without logging in / without a cookie) in my case.

meichthys commented 1 year ago

Please try using SSL: https://github.com/meichthys/uptime_kuma/issues/33#issuecomment-1482738545

meichthys commented 1 year ago

Closing. If you still have an issue, please update HA and UK and re-file with some additional logs.

coax commented 1 year ago

I've stubled upon this as well. The solution is trivial, you need to enter http:// along with your hostname or IP address when setting up.

My setup in Docker containers:

Host/URL*:
http://localhost

Port:
3001

Username*:
<username>

Password*:
<password>

Verify SSL certificate:
not checked