failed to initialize database, got error failed to connect to host=db user=postgres database=postgres: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving #8488

Closed
opened 2026-02-21 18:25:57 -05:00 by yindo · 3 comments
Owner

Originally created by @Smart-Bobo on GitHub (Feb 21, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

a97d73a

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

docker-sandbox-1 | 2025/02/21 05:39:31 env.go:30: [WARN]python lib path /run/systemd/resolve/stub-resolv.conf is not available
docker-sandbox-1 | 2025/02/21 05:39:31 env.go:30: [WARN]python lib path /run/resolvconf/resolv.conf is not available
docker-sandbox-1 | [GIN] 2025/02/21 - 05:39:34 | 200 | 53.897µs | 127.0.0.1 | GET "/health"
docker-weaviate-1 | {"action":"read_disk_use","level":"warning","msg":"disk usage currently at 89.86%, threshold set to 80.00%","path":"/var/lib/weaviate","time":"2025-02-21T05:39:38Z"}
docker-sandbox-1 | 2025/02/21 05:39:40 server.go:60: [INFO]python dependencies sandbox initialized
docker-sandbox-1 | [GIN] 2025/02/21 - 05:39:40 | 404 | 1.351µs | :: | GET "/squid-internal-dynamic/netdb"
docker-plugin_daemon-1 | 2025/02/21 05:39:44 pool.go:32: [INFO]init routine pool, size: 10000
docker-plugin_daemon-1 |
docker-plugin_daemon-1 | 2025/02/21 05:39:44 /app/internal/db/init.go:17
docker-plugin_daemon-1 | [error] failed to initialize database, got error failed to connect to host=db user=postgres database=postgres: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving)
docker-plugin_daemon-1 | 2025/02/21 05:39:44 init.go:103: [PANIC]failed to init dify plugin db: failed to connect to host=db user=postgres database=postgres: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving)
docker-plugin_daemon-1 | panic: [PANIC]failed to init dify plugin db: failed to connect to host=db user=postgres database=postgres: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving)%!(EXTRA *pgconn.ConnectError=failed to connect to host=db user=postgres database=postgres: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving))
docker-plugin_daemon-1 |
docker-plugin_daemon-1 | goroutine 1 [running]:
docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.writeLog({0x15cf074, 0x5}, {0x15fc583?, 0x2?}, 0x1, {0xc00063fd00, 0x1, 0x1})
docker-plugin_daemon-1 | /app/internal/utils/log/log.go:40 +0x326
docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.Panic(...)
docker-plugin_daemon-1 | /app/internal/utils/log/log.go:66
docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/db.Init(0x2710?)
docker-plugin_daemon-1 | /app/internal/db/init.go:103 +0xbb
docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/server.(*App).Run(0xc0001aaa50, 0xc0002c9b88)
docker-plugin_daemon-1 | /app/internal/server/server.go:55 +0xd2
docker-plugin_daemon-1 | main.main()
docker-plugin_daemon-1 | /app/cmd/server/main.go:28 +0xff

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @Smart-Bobo on GitHub (Feb 21, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version a97d73a ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce docker-sandbox-1 | 2025/02/21 05:39:31 env.go:30: [WARN]python lib path /run/systemd/resolve/stub-resolv.conf is not available docker-sandbox-1 | 2025/02/21 05:39:31 env.go:30: [WARN]python lib path /run/resolvconf/resolv.conf is not available docker-sandbox-1 | [GIN] 2025/02/21 - 05:39:34 | 200 | 53.897µs | 127.0.0.1 | GET "/health" docker-weaviate-1 | {"action":"read_disk_use","level":"warning","msg":"disk usage currently at 89.86%, threshold set to 80.00%","path":"/var/lib/weaviate","time":"2025-02-21T05:39:38Z"} docker-sandbox-1 | 2025/02/21 05:39:40 server.go:60: [INFO]python dependencies sandbox initialized docker-sandbox-1 | [GIN] 2025/02/21 - 05:39:40 | 404 | 1.351µs | :: | GET "/squid-internal-dynamic/netdb" docker-plugin_daemon-1 | 2025/02/21 05:39:44 pool.go:32: [INFO]init routine pool, size: 10000 docker-plugin_daemon-1 | docker-plugin_daemon-1 | 2025/02/21 05:39:44 /app/internal/db/init.go:17 docker-plugin_daemon-1 | [error] failed to initialize database, got error failed to connect to `host=db user=postgres database=postgres`: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving) docker-plugin_daemon-1 | 2025/02/21 05:39:44 init.go:103: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving) docker-plugin_daemon-1 | panic: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving)%!(EXTRA *pgconn.ConnectError=failed to connect to `host=db user=postgres database=postgres`: hostname resolving error (lookup db on 127.0.0.11:53: server misbehaving)) docker-plugin_daemon-1 | docker-plugin_daemon-1 | goroutine 1 [running]: docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.writeLog({0x15cf074, 0x5}, {0x15fc583?, 0x2?}, 0x1, {0xc00063fd00, 0x1, 0x1}) docker-plugin_daemon-1 | /app/internal/utils/log/log.go:40 +0x326 docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.Panic(...) docker-plugin_daemon-1 | /app/internal/utils/log/log.go:66 docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/db.Init(0x2710?) docker-plugin_daemon-1 | /app/internal/db/init.go:103 +0xbb docker-plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/server.(*App).Run(0xc0001aaa50, 0xc0002c9b88) docker-plugin_daemon-1 | /app/internal/server/server.go:55 +0xd2 docker-plugin_daemon-1 | main.main() docker-plugin_daemon-1 | /app/cmd/server/main.go:28 +0xff ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:25:57 -05:00
yindo closed this issue 2026-02-21 18:25:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 21, 2025):

Hey @Smart-Bobo! I'm here to assist you with any bugs, questions, or contributions. Let's get this issue sorted out together!

To resolve the hostname resolving error when trying to connect to the database in your self-hosted Docker environment using Dify, follow these steps:

  1. Check if the Database Container is Running Properly: Use the command below to ensure that the database container is up and running:

    docker ps
    
  2. Restart the Services: If the database container is not running or if there are issues, stop all containers and remove existing volumes, then restart the services:

    docker compose down
    docker compose up -d
    
  3. Verify Docker Network Configuration: Ensure that the Docker network settings are correctly configured. The default network settings for Dify include using a bridge network, which should allow containers to communicate with each other. Check your docker-compose.yaml file for network configurations.

  4. Check Environment Variables: Make sure that the environment variables in your docker-compose.yaml file are correctly set, especially those related to the database connection.

  5. Apply Database Migrations: Ensure that the necessary database migrations are applied to create the required tables.

These steps should help resolve the connection issues by ensuring that the database service is correctly configured and running [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 21, 2025): <!-- Greeting --> Hey @Smart-Bobo! I'm here to assist you with any bugs, questions, or contributions. Let's get this issue sorted out together! <!-- Answer --> To resolve the hostname resolving error when trying to connect to the database in your self-hosted Docker environment using Dify, follow these steps: 1. **Check if the Database Container is Running Properly**: Use the command below to ensure that the database container is up and running: ```bash docker ps ``` 2. **Restart the Services**: If the database container is not running or if there are issues, stop all containers and remove existing volumes, then restart the services: ```bash docker compose down docker compose up -d ``` 3. **Verify Docker Network Configuration**: Ensure that the Docker network settings are correctly configured. The default network settings for Dify include using a `bridge` network, which should allow containers to communicate with each other. Check your `docker-compose.yaml` file for network configurations. 4. **Check Environment Variables**: Make sure that the environment variables in your `docker-compose.yaml` file are correctly set, especially those related to the database connection. 5. **Apply Database Migrations**: Ensure that the necessary database migrations are applied to create the required tables. These steps should help resolve the connection issues by ensuring that the database service is correctly configured and running <sup>[[1]](https://github.com/langgenius/dify/issues/13540)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=other)</sup>
Author
Owner

@Smart-Bobo commented on GitHub (Feb 21, 2025):

Hey @Smart-Bobo! I'm here to assist you with any bugs, questions, or contributions. Let's get this issue sorted out together!嘿 @Smart-Bobo!我在这里帮助你解决任何错误、问题或贡献。让我们一起解决这个问题吧!

To resolve the hostname resolving error when trying to connect to the database in your self-hosted Docker environment using Dify, follow these steps:要解决在尝试使用 Dify 连接到自托管 Docker 环境中的数据库时出现主机名解析错误,请执行以下步骤:

  1. Check if the Database Container is Running Properly: Use the command below to ensure that the database container is up and running:检查数据库容器是否正常运行:使用以下命令确保数据库容器已启动并正在运行:
    docker ps
  2. Restart the Services: If the database container is not running or if there are issues, stop all containers and remove existing volumes, then restart the services:重新启动服务:如果数据库容器未运行或出现问题,请停止所有容器并删除现有卷,然后重新启动服务:
    docker compose down
    docker compose up -d
  3. Verify Docker Network Configuration: Ensure that the Docker network settings are correctly configured. The default network settings for Dify include using a bridge network, which should allow containers to communicate with each other. Check your docker-compose.yaml file for network configurations.验证 Docker 网络配置:确保 Docker 网络设置配置正确。Dify 的默认网络设置包括使用bridge网络,这应该允许容器相互通信。检查您的 docker-compose.yaml 文件以获取网络配置。
  4. Check Environment Variables: Make sure that the environment variables in your docker-compose.yaml file are correctly set, especially those related to the database connection.检查环境变量:确保 docker-compose.yaml 文件中的环境变量设置正确,尤其是与数据库连接相关的环境变量。
  5. Apply Database Migrations: Ensure that the necessary database migrations are applied to create the required tables.应用数据库迁移:确保应用必要的数据库迁移以创建所需的表。

These steps should help resolve the connection issues by ensuring that the database service is correctly configured and running [1].这些步骤应该通过确保数据库服务正确配置并运行 [1] 来帮助解决连接问题。

To continue talking to Dosu, mention @dosu.要继续与 Dosu 交谈,请提及 @dosu

Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other帮助 Dosu 学习!给它反馈:伟大的回应 |无关紧要的答案 |不正确的来源 |太冗长 |幻觉 |Bug 报告 |其他

fcb3650d08bd langgenius/dify-plugin-daemon:0.0.2-local "/bin/bash -c /app/e…" 42 seconds ago Restarting (2) 1 second ago docker-plugin_daemon-1
f3097832af60 langgenius/dify-sandbox:0.2.10 "/main" 42 seconds ago Up 40 seconds (healthy) docker-sandbox-1
c1e2cc94d37b langgenius/dify-web:0.15.3 "/bin/sh ./entrypoin…" 42 seconds ago Up 36 seconds 3000/tcp docker-web-1
285bc5669ede ubuntu/squid:latest "sh -c 'cp /docker-e…" 42 seconds ago Up 37 seconds 3128/tcp docker-ssrf_proxy-1
a5d97f73b027 redis:6-alpine "docker-entrypoint.s…" 42 seconds ago Up 38 seconds (healthy) 6379/tcp docker-redis-1
77ba42448630 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" 42 seconds ago Up 39 seconds docker-weaviate-1

i not change docker-compose.yaml,and this in myfirst time to use dify

@Smart-Bobo commented on GitHub (Feb 21, 2025): > Hey [@Smart-Bobo](https://github.com/Smart-Bobo)! I'm here to assist you with any bugs, questions, or contributions. Let's get this issue sorted out together!嘿 [@Smart-Bobo](https://github.com/Smart-Bobo)!我在这里帮助你解决任何错误、问题或贡献。让我们一起解决这个问题吧! > > To resolve the hostname resolving error when trying to connect to the database in your self-hosted Docker environment using Dify, follow these steps:要解决在尝试使用 Dify 连接到自托管 Docker 环境中的数据库时出现主机名解析错误,请执行以下步骤: > > 1. **Check if the Database Container is Running Properly**: Use the command below to ensure that the database container is up and running:**检查数据库容器是否正常运行**:使用以下命令确保数据库容器已启动并正在运行: > docker ps > 2. **Restart the Services**: If the database container is not running or if there are issues, stop all containers and remove existing volumes, then restart the services:**重新启动服务**:如果数据库容器未运行或出现问题,请停止所有容器并删除现有卷,然后重新启动服务: > docker compose down > docker compose up -d > 3. **Verify Docker Network Configuration**: Ensure that the Docker network settings are correctly configured. The default network settings for Dify include using a `bridge` network, which should allow containers to communicate with each other. Check your `docker-compose.yaml` file for network configurations.**验证 Docker 网络配置**:确保 Docker 网络设置配置正确。Dify 的默认网络设置包括使用`bridge`网络,这应该允许容器相互通信。检查您的 `docker-compose.yaml` 文件以获取网络配置。 > 4. **Check Environment Variables**: Make sure that the environment variables in your `docker-compose.yaml` file are correctly set, especially those related to the database connection.**检查环境变量**:确保 `docker-compose.yaml` 文件中的环境变量设置正确,尤其是与数据库连接相关的环境变量。 > 5. **Apply Database Migrations**: Ensure that the necessary database migrations are applied to create the required tables.**应用数据库迁移**:确保应用必要的数据库迁移以创建所需的表。 > > These steps should help resolve the connection issues by ensuring that the database service is correctly configured and running [[1]](https://github.com/langgenius/dify/issues/13540).这些步骤应该通过确保数据库服务正确配置并运行 [[1]](https://github.com/langgenius/dify/issues/13540) 来帮助解决连接问题。 > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu).要继续与 [Dosu](https://dosu.dev) 交谈,请提及 [@dosu](https://github.com/dosu)。_ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=other)帮助 Dosu 学习!给它反馈:[伟大的回应](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=great_response) |[无关紧要的答案](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=irrelevant_answer) |[不正确的来源](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=incorrect_sources) |[太冗长](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=too_verbose) |[幻觉](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=hallucination) |[Bug 报告](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=bug_report) |[其他](https://app.dosu.dev/response-feedback/db11201f-b93d-4559-920d-23380735e00b?feedback_type=other) fcb3650d08bd langgenius/dify-plugin-daemon:0.0.2-local "/bin/bash -c /app/e…" 42 seconds ago Restarting (2) 1 second ago docker-plugin_daemon-1 f3097832af60 langgenius/dify-sandbox:0.2.10 "/main" 42 seconds ago Up 40 seconds (healthy) docker-sandbox-1 c1e2cc94d37b langgenius/dify-web:0.15.3 "/bin/sh ./entrypoin…" 42 seconds ago Up 36 seconds 3000/tcp docker-web-1 285bc5669ede ubuntu/squid:latest "sh -c 'cp /docker-e…" 42 seconds ago Up 37 seconds 3128/tcp docker-ssrf_proxy-1 a5d97f73b027 redis:6-alpine "docker-entrypoint.s…" 42 seconds ago Up 38 seconds (healthy) 6379/tcp docker-redis-1 77ba42448630 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" 42 seconds ago Up 39 seconds docker-weaviate-1 i not change docker-compose.yaml,and this in myfirst time to use dify
Author
Owner

@Scenx commented on GitHub (Mar 3, 2025):

fuck me too im remote pg-rds

@Scenx commented on GitHub (Mar 3, 2025): fuck me too im remote pg-rds
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8488