Setup w/ postgreSQL error: "connect: no route to host"

I wanna try hosting Gitea with Postgresql on my openEuler server. I have the following docker-compose.yml.

version: "3.7"

services:
  server:
    image: gitea/gitea:1
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./data/gitea:/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "8000:3000"
      - "8022:22"
    depends_on:
      - db
  db:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - ./data/postgres:/var/lib/postgresql/data

networks:
  gitea:
    name: gitea-net

Things are pretty much the same from gitea website tutorial.

Environment setup:

  1. Gitea is running on Docker 18.09 on a openEuler 22.03 SP1 server (freshly installed)
  2. Trying to access Gitea on another PC

On my PC, I accessed Gitea via Chrome 192.168.50.58:8000. I can see the nice Setup page. I checked “Enable Local Mode” and added admin account. That’s it. I left the Database section untouched. They are pre-filled with the following data:

Database Type: PostgreSQL
Host: db:5432
Username: gitea
Password: gitea (I typed it again to ensure)
Database Name: gitea
SSL: Disabled
Schema: (blank)

Then I click “Install Gitea” and the following error is shown on top, and the fields in Database section is filled with red color.

The database settings are invalid: dial tcp 172.19.0.2:5432: connect: no route to host

I googled and done this:

firewall-cmd --permanent --zone=public --add-rich-rule='rule family=ipv4 source address=172.19.0.0/16 accept'
firewall-cmd --permanent --zone=public --add-masquerade
firewall-cmd --reload
systemctl restart firewalld # (just in case)
systemctl restart docker

But still the two containers are not communicating with each other (or so I think).

Any ideas?


Extra info

# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eno1
  sources:
  services: dhcpv6-client mdns ssh
  ports: 8000/tcp
  protocols:
  forward: yes
  masquerade: yes
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
        rule family="ipv4" source address="172.19.0.0/16" accept
# docker version
Client:
 Version:           18.09.0
 EulerVersion:      18.09.0.316
 API version:       1.39
 Go version:        go1.17.3
 Git commit:        9b9af2f
 Built:             Tue Dec 27 14:25:30 2022
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.0
  EulerVersion:     18.09.0.316
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.17.3
  Git commit:       9b9af2f
  Built:            Tue Dec 27 14:24:56 2022
  OS/Arch:          linux/amd64
  Experimental:     false
# docker-compose --version
docker-compose version 1.22.0, build f46880f

I have successfully solved it by manually installing Docker 23. I didn’t even change the docker-compose.yml. Guess it’s the docker engine version too low

1 Like

Glad you figured it out. I’m assuming Postgres was the issue in Docker and am not sure what version they recommend, but Gitea recommends at least Docker server 20.10.6 otherwise you run into issues with webhooks not working so upgrading was a good idea.

1 Like