louislam / uptime-kuma

A fancy self-hosted monitoring tool

Home Page:https://uptime.kuma.pet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Postgres connection timeout

stuzer05 opened this issue Β· comments

πŸ“‘ I have found these related issues/pull requests

Tried to setup PostgreSQL with custom port but getting connection timout

postgresql://root:root@127.0.0.1:4743/postgres
postgres://root:root@127.0.0.1:4743/postgres

πŸ›‘οΈ Security Policy

Description

No response

πŸ‘Ÿ Reproduction steps

Add PostgreSQL

πŸ‘€ Expected behavior

Successful ping

πŸ˜“ Actual Behavior

connect ETIMEDOUT 127.0.0.1:4743

🐻 Uptime-Kuma Version

latest docker

πŸ’» Operating System and Arch

debian

🌐 Browser

firefox

πŸ–₯️ Deployment Environment

  • Runtime: docker
  • Database: -
  • Filesystem used to store the database on: -
  • number of monitors: -

πŸ“ Relevant log output

No response

Could you add details about your environment and what you are trying to monitor?
You forgot to fill out most of the form which makes it hard to provide actionable help.

In particular: what docker-network are you using? Where is the posters container in relation to uptime Kuma?

I try to monitor postgresql database using these DSN's (redacted host) with custom postgresql port. But gitea can't reach the database and throws connect ETIMEDOUT <ip>:4743 error

postgresql://root:root@<ip>:4743/postgres
postgres://root:root@<ip>:4743/postgres

But gitea can't reach the database and throws connect ETIMEDOUT <ip>:4743 error

This is Uptime Kuma, not gitea.

Also, you did not answer the questions I asked of you:

Could you add details about your environment and what you are trying to monitor?
You forgot to fill out most of the form which makes it hard to provide actionable help.

In particular:

  • what docker-network are you using?
  • Where is the postgres container in relation to uptime Kuma?

Tip

In case you did not know: docker has more than one network type with only some of them allowing access to the local network and some not even allowing access to remote networks

what docker-network are you using?

I run Uptime Kuma in default network as all the containers like so

docker run -d \
  --label=com.centurylinklabs.watchtower.enable=true \
  --restart=unless-stopped \
  -p 127.0.0.1:3001:3001 \
  -v uptime-kuma:/app/data \
  --name uptime-kuma \
  louislam/uptime-kuma:latest

Uptime Kuma can see MariaDB but not postgres with the same docker container options

docker run -d \
  --restart=unless-stopped \
  -p 4742:3306 \
  -p 127.0.0.1:33060:33060 \
  -v mariadb-data:/var/lib/mysql \
  -e MARIADB_ROOT_PASSWORD=root \
  --name mariadb \
  mariadb:latest

docker run -d \
  --restart=unless-stopped \
  -v postgres:/var/lib/postgresql/data \
  -e POSTGRES_USER=root \
  -e POSTGRES_PASSWORD=root \
  -p 4743:5432 \
  --name postgres \
  postgres

Where is the postgres container in relation to uptime Kuma?

On the same host, all the docker commands are above. MariaDB works with Uptime Kuma mysql://root:root@example.com:4742 but postgres doesn't postgresql://root:root@example.com:4743/postgres

Not sure if this is the cause but it may have to do with the listening address you have configured for the postgres instance.

https://stackoverflow.com/questions/48341164/how-to-make-postgres-docker-accessible-for-any-ip-remotely

postgres is accessible from anywhere, I've checked that. I suspect Kuma doesn't support custom port

I have tried to reproduce your example from above and Uptime Kuma and MariaDB cannot communicate.
=> please provide further details about your environment and how to create it reliably (including what you put at example.com in the connection strings)

I think this is because of your docker-network configuration and that the -p.

When I put them into the same network, everything works as expected:

version: '3.8'

services:
  uptime-kuma:
    image: louislam/uptime-kuma:latest
    ports:
      - "127.0.0.1:3001:3001"
  mariadb:
    image: mariadb:latest
    ports:
      - "4742:3306"
    environment:
      - MARIADB_ROOT_PASSWORD=root
  postgres:
    image: postgres
    ports:
      - "4743:5432"
    environment:
      - POSTGRES_USER=root
      - POSTGRES_PASSWORD=root

image

I found out that ufw was the problem. Postgres port wasn't allowed in firewall. Kuma and postgres are running on the same host. But I used a domain name in dsn for postgresql. However, for some reason, I can connect to postgres in dbeaver from by home.