From 785269c1c2aa8b7dc4ec3a558cf35512cd20bd6b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 10 May 2026 02:53:50 +0000 Subject: [PATCH] fix: force IPv4 for MariaDB connections in photoprism to resolve HAOS 17.3 IPv6 issue Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/4d98e9f3-cdc8-4e3e-b631-1bbd56309cb8 Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- photoprism/CHANGELOG.md | 4 ++++ photoprism/config.yaml | 2 +- photoprism/rootfs/etc/cont-init.d/99-run.sh | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/photoprism/CHANGELOG.md b/photoprism/CHANGELOG.md index 38ddfede47..59def79c52 100644 --- a/photoprism/CHANGELOG.md +++ b/photoprism/CHANGELOG.md @@ -1,4 +1,8 @@ +## ubuntu-2026-03-05-1 (2026-05-10) + +- Fix: Force IPv4 for MariaDB connections to resolve access denied errors after HAOS 17.3 (IPv6 networking change) + ## ubuntu-2026-03-05 (2026-03-05) - Update to latest version from photoprism/photoprism ## ubuntu-2025-11-30-4 (26-02-2026) diff --git a/photoprism/config.yaml b/photoprism/config.yaml index fa50c736cd..6443154f63 100644 --- a/photoprism/config.yaml +++ b/photoprism/config.yaml @@ -131,5 +131,5 @@ services: slug: photoprism udev: true url: https://github.com/alexbelgium/hassio-addons -version: "ubuntu-2026-03-05" +version: "ubuntu-2026-03-05-1" video: true diff --git a/photoprism/rootfs/etc/cont-init.d/99-run.sh b/photoprism/rootfs/etc/cont-init.d/99-run.sh index 68b566a079..035b28a24b 100755 --- a/photoprism/rootfs/etc/cont-init.d/99-run.sh +++ b/photoprism/rootfs/etc/cont-init.d/99-run.sh @@ -30,7 +30,16 @@ case $(bashio::config 'DB_TYPE') in # Use values PHOTOPRISM_DATABASE_DRIVER="mysql" - PHOTOPRISM_DATABASE_SERVER="$(bashio::services 'mysql' 'host'):$(bashio::services 'mysql' 'port')" + MYSQL_HOST="$(bashio::services 'mysql' 'host')" + MYSQL_PORT="$(bashio::services 'mysql' 'port')" + + # Force IPv4 to avoid access denied errors when the container network uses IPv6 (HAOS 17.3+) + if MYSQL_HOST_V4=$(getent ahostsv4 "$MYSQL_HOST" 2>/dev/null | awk 'NR==1{print $1}') && [ -n "$MYSQL_HOST_V4" ]; then + bashio::log.info "Resolved MariaDB host to IPv4: $MYSQL_HOST_V4" + MYSQL_HOST="$MYSQL_HOST_V4" + fi + + PHOTOPRISM_DATABASE_SERVER="${MYSQL_HOST}:${MYSQL_PORT}" PHOTOPRISM_DATABASE_NAME="photoprism" PHOTOPRISM_DATABASE_USER="$(bashio::services 'mysql' 'username')" PHOTOPRISM_DATABASE_PASSWORD="$(bashio::services 'mysql' 'password')" @@ -58,9 +67,9 @@ case $(bashio::config 'DB_TYPE') in bashio::log.warning "Uninstalling the MariaDB addon will remove any data" # Create database - mysql --skip-ssl --host="$(bashio::services 'mysql' 'host')" --port="$(bashio::services 'mysql' 'port')" --user="$PHOTOPRISM_DATABASE_USER" --password="$PHOTOPRISM_DATABASE_PASSWORD" -e"CREATE DATABASE IF NOT EXISTS $PHOTOPRISM_DATABASE_NAME;" + mysql --skip-ssl --host="$MYSQL_HOST" --port="$MYSQL_PORT" --user="$PHOTOPRISM_DATABASE_USER" --password="$PHOTOPRISM_DATABASE_PASSWORD" -e"CREATE DATABASE IF NOT EXISTS $PHOTOPRISM_DATABASE_NAME;" # Force character set - mysql --skip-ssl --host="$(bashio::services 'mysql' 'host')" --port="$(bashio::services 'mysql' 'port')" --user="$PHOTOPRISM_DATABASE_USER" --password="$PHOTOPRISM_DATABASE_PASSWORD" -e"ALTER DATABASE $PHOTOPRISM_DATABASE_NAME CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;" || true + mysql --skip-ssl --host="$MYSQL_HOST" --port="$MYSQL_PORT" --user="$PHOTOPRISM_DATABASE_USER" --password="$PHOTOPRISM_DATABASE_PASSWORD" -e"ALTER DATABASE $PHOTOPRISM_DATABASE_NAME CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;" || true ;; esac