NathanVaughn / webtrees-docker

Up-to-date Docker image for webtrees with all the bells and whistles.
https://hub.docker.com/r/nathanvaughn/webtrees
MIT License
64 stars 15 forks source link

Got accidentaly error : RuntimeException: SQLSTATE[HY000] [2002] No route to host #152

Closed ocidserver closed 1 week ago

ocidserver commented 2 weeks ago

i got this error after running well for a week. accidentaly crash and cannot get in to. container become unhealty on portainer. help me to solve

RuntimeException: SQLSTATE[HY000] [2002] No route to host in /var/www/webtrees/app/Http/Middleware/UseDatabase.php:119

NathanVaughn commented 2 weeks ago

Do you have the hostname and port right for your database server? That error means it can't reach it. Especially with Docker compose, it's important to make sure you're using the right hostname.

ocidserver commented 2 weeks ago

i use this

services:
  app:
    depends_on:
      - db
    environment:
      PRETTY_URLS: "1"
      HTTPS: "0"
      HTTPS_REDIRECT: "0"
      LANG: "en-US"
      DB_TYPE: "mysql"
      DB_HOST: "db"
      DB_PORT: "3306"
      DB_USER: "webtrees"
      DB_PASS: "baddbpassword"
      DB_NAME: "webtrees"
      DB_PREFIX: "wt_"
      WT_USER: "admin"
      PUID: "1000"
      PGID: "1000"
    image: ghcr.io/nathanvaughn/webtrees:latest
    ports:
      - 8700:80
      # - 443:443
    restart: unless-stopped
    volumes:
      # - ~/certs:/certs/
      - app_data:/var/www/webtrees/data/

  db:
    environment:
      MARIADB_DATABASE: "webtrees"
      MARIADB_USER: "webtrees"
      MARIADB_ROOT_PASSWORD: "badrootpassword"
      MARIADB_PASSWORD: "baddbpassword"
    # See: https://github.com/NathanVaughn/webtrees-docker/issues/145
    image: docker.io/library/mariadb:11
    restart: unless-stopped
    volumes:
      - db_data:/var/lib/mysql

  # db:
  #   environment:
  #     POSTGRES_DB: "webtrees"
  #     POSTGRES_USER: "webtrees"
  #     POSTGRES_PASSWORD: "badpassword"
  #   image: docker.io/library/postgres:latest
  #   restart: unless-stopped
  #   volumes:
  #     - db_data:/var/lib/postgresql/data

volumes:
  db_data:
    driver: local
  app_data:
    driver: local
NathanVaughn commented 1 week ago

I tried that docker-compose stack and had no issues. What you can do is attach a shell to the container and check the contents of /var/www/webtrees/data/config.ini.php image

Additionally, run mysqladmin and see if the container can even reach the database. image

Or install ping and check that the database is responding that way:

apt update
apt install iputils-ping
ping db
ocidserver commented 1 week ago

already try to inspect in console, Screenshot 2024-11-11 085749 im try to connect db from dbeaver and no issue. i use portainer to manage network, its already in the same network.

ocidserver commented 1 week ago

already solve, im try to re-run docker compose. i think this way will erase all db, but its all safe. thx dude