[PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused) in docker 1.0
Self Checks
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
1.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
git clone the newest copy the .env file and rename
✔️ Expected Behavior
when i goto localhost:80/install it show an error tip and below is all the logs
❌ Actual Behavior
docker compose up -d
[+] Running 68/68
✔ web Pulled 164.3s
✔ weaviate Pulled 44.1s
✔ ssrf_proxy Pulled 31.6s
✔ plugin_daemon Pulled 145.5s
✔ db Pulled 136.9s
✔ redis Pulled 111.8s
✔ sandbox Pulled 144.9s
✔ api Pulled 188.3s
✔ worker Pulled 188.1s
✔ nginx Pulled 135.8s
[+] Running 12/12
✔ Network docker_ssrf_proxy_network Created 0.5s
✔ Network docker_default Created 0.4s
✔ Container docker-redis-1 Started 100.4s
✔ Container docker-web-1 Started 97.5s
✔ Container docker-plugin_daemon-1 Started 105.5s
✔ Container docker-sandbox-1 Started 98.2s
✔ Container docker-ssrf_proxy-1 Started 106.8s
✔ Container docker-db-1 Started 100.0s
✔ Container docker-weaviate-1 Started 102.6s
✔ Container docker-worker-1 Started 26.0s
✔ Container docker-api-1 Started 24.9s
✔ Container docker-nginx-1 Started 27.6s
E:\dify\dify\docker>docker compose logs
weaviate-1 | {"action":"startup","default_vectorizer_module":"none","level":"info","msg":"the default vectorizer modules is set to \"none\", as a result all new schema classes without an explicit vectorizer setting, will use this vectorizer","time":"2025-03-01T10:34:59Z"}
weaviate-1 | {"action":"startup","auto_schema_enabled":true,"level":"info","msg":"auto schema enabled setting is set to \"true\"","time":"2025-03-01T10:34:59Z"}
weaviate-1 | {"action":"grpc_startup","level":"info","msg":"grpc server listening at [::]:50051","time":"2025-03-01T10:35:01Z"}
weaviate-1 | {"action":"restapi_management","level":"info","msg":"Serving weaviate at http://[::]:8080","time":"2025-03-01T10:35:01Z"}
weaviate-1 | {"action":"read_disk_use","level":"warning","msg":"disk usage currently at 91.76%, threshold set to 80.00%","path":"/var/lib/weaviate","time":"2025-03-01T10:35:30Z"}
sandbox-1 | 2025/03/01 10:34:55 setup.go:29: [INFO]initializing nodejs runner environment...
ssrf_proxy-1 | [ENTRYPOINT] re-create snakeoil self-signed certificate removed in the build process
ssrf_proxy-1 | [ENTRYPOINT] replacing environment variables in the template
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/squid.conf (depth 0)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/conf.d/debian.conf (depth 1)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/conf.d/rock.conf (depth 1)
ssrf_proxy-1 | 2025/03/01 10:35:05| Created PID file (/run/squid.pid)
ssrf_proxy-1 | 2025/03/01 10:35:05| Set Current Directory to /var/spool/squid
ssrf_proxy-1 | 2025/03/01 10:35:05| Creating missing swap directories
ssrf_proxy-1 | 2025/03/01 10:35:05| No cache_dir stores are configured.
ssrf_proxy-1 | 2025/03/01 10:35:05| Removing PID file (/run/squid.pid)
ssrf_proxy-1 | [ENTRYPOINT] starting squid
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/squid.conf (depth 0)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/conf.d/debian.conf (depth 1)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/conf.d/rock.conf (depth 1)
ssrf_proxy-1 | 2025/03/01 10:35:05| Created PID file (/run/squid.pid)
ssrf_proxy-1 | 2025/03/01 10:35:05| Set Current Directory to /var/spool/squid
ssrf_proxy-1 | 2025/03/01 10:35:05| Creating missing swap directories
ssrf_proxy-1 | 2025/03/01 10:35:05| No cache_dir stores are configured.
ssrf_proxy-1 | 2025/03/01 10:35:05| Removing PID file (/run/squid.pid)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/squid.conf (depth 0)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/conf.d/debian.conf (depth 1)
ssrf_proxy-1 | 2025/03/01 10:35:05| Processing Configuration File: /etc/squid/conf.d/rock.conf (depth 1)
ssrf_proxy-1 | 2025/03/01 10:35:06| Created PID file (/run/squid.pid)
ssrf_proxy-1 | 2025/03/01 10:35:06| Set Current Directory to /var/spool/squid
ssrf_proxy-1 | 2025/03/01 10:35:06| Starting Squid Cache version 6.10 for x86_64-pc-linux-gnu...
sandbox-1 | 2025/03/01 10:34:55 setup.go:85: [INFO]nodejs runner environment initialized
worker-1 | Running migrations
worker-1 | 2025-03-01 10:35:14.475 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 32 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
worker-1 | 2025-03-01 10:35:14.475 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads.
worker-1 | /app/api/.venv/lib/python3.12/site-packages/opik/evaluation/metrics/heuristics/regex_match.py:8: SyntaxWarning: invalid escape sequence '\d'
worker-1 | """
worker-1 | 2025-03-01 10:35:18.092 INFO [MainThread] [_client.py:1038] - HTTP Request: GET https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json "HTTP/1.1 200 OK"
weaviate-1 | {"action":"set_shard_read_only","level":"warning","msg":"Set READONLY, disk usage currently at 91.76%, threshold set to 90.00%","path":"/var/lib/weaviate","time":"2025-03-01T10:35:30Z"}
web-1 |
web-1 | -------------
web-1 |
web-1 | __/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
web-1 | _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
web-1 | _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
web-1 | _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
web-1 | _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
web-1 | _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
web-1 | _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
web-1 | _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
web-1 | _\///______________\///______________\///__\///////////////__
web-1 |
web-1 |
web-1 | Runtime Edition
web-1 |
web-1 | PM2 is a Production Process Manager for Node.js applications
web-1 | with a built-in Load Balancer.
web-1 |
web-1 | Start and Daemonize any application:
web-1 | $ pm2 start app.js
web-1 |
web-1 | Load Balance 4 instances of api.js:
web-1 | $ pm2 start api.js -i 4
web-1 |
web-1 | Monitor in production:
web-1 | $ pm2 monitor
web-1 |
web-1 | Make pm2 auto-boot at server restart:
web-1 | $ pm2 startup
web-1 |
web-1 | To go further checkout:
web-1 | http://pm2.io/
web-1 |
web-1 |
web-1 | -------------
web-1 |
web-1 | pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
web-1 | 2025-03-01T10:34:55: PM2 log: Launching in no daemon mode
web-1 | 2025-03-01T10:34:55: PM2 log: [PM2] Starting /app/web/server.js in cluster_mode (2 instances)
web-1 | 2025-03-01T10:34:55: PM2 log: App [dify-web:0] starting in -cluster mode-
web-1 | 2025-03-01T10:34:55: PM2 log: App [dify-web:0] online
web-1 | 2025-03-01T10:34:55: PM2 log: App [dify-web:1] starting in -cluster mode-
web-1 | 2025-03-01T10:34:55: PM2 log: App [dify-web:1] online
web-1 | 2025-03-01T10:34:55: PM2 log: [PM2] Done.
web-1 | 2025-03-01T10:34:55: PM2 log: ┌────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
web-1 | │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
web-1 | ├────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
web-1 | │ 0 │ dify-web │ default │ 1.0.0 │ cluster │ 23 │ 0s │ 0 │ online │ 0% │ 52.3mb │ undefin… │ disabled │
web-1 | │ 1 │ dify-web │ default │ 1.0.0 │ cluster │ 30 │ 0s │ 0 │ online │ 0% │ 49.6mb │ undefin… │ disabled │
web-1 | └────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
web-1 | 2025-03-01T10:34:55: PM2 log: [--no-daemon] Continue to stream logs
web-1 | 2025-03-01T10:34:55: PM2 log: [--no-daemon] Exit on target PM2 exit pid=7
web-1 | 10:34:55 0|dify-web | ▲ Next.js 14.2.15
web-1 | 10:34:55 0|dify-web | - Local: http://f4801843c4d7:3000
web-1 | 10:34:55 0|dify-web | - Network: http://172.19.0.2:3000
web-1 | 10:34:55 0|dify-web | ✓ Starting...
web-1 | 10:34:55 1|dify-web | ▲ Next.js 14.2.15
web-1 | 10:34:55 1|dify-web | - Local: http://f4801843c4d7:3000
web-1 | 10:34:55 1|dify-web | - Network: http://172.19.0.2:3000
web-1 | 10:34:55 1|dify-web | ✓ Starting...
web-1 | 10:34:55 0|dify-web | ✓ Ready in 54ms
web-1 | 10:34:55 1|dify-web | ✓ Ready in 56ms
redis-1 | 1:C 01 Mar 2025 10:34:57.876 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
db-1 | The files belonging to this database system will be owned by user "postgres".
db-1 | This user must also own the server process.
db-1 |
db-1 | The database cluster will be initialized with locale "en_US.utf8".
db-1 | The default database encoding has accordingly been set to "UTF8".
db-1 | The default text search configuration will be set to "english".
db-1 |
db-1 | Data page checksums are disabled.
db-1 |
db-1 | fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... ok
db-1 | creating subdirectories ... ok
db-1 | selecting dynamic shared memory implementation ... posix
db-1 | selecting default max_connections ... 100
db-1 | selecting default shared_buffers ... 128MB
db-1 | selecting default time zone ... UTC
db-1 | creating configuration files ... ok
db-1 | running bootstrap script ... ok
db-1 | sh: locale: not found
db-1 | 2025-03-01 10:35:02.983 UTC [60] WARNING: no usable system locales were found
db-1 | performing post-bootstrap initialization ... ok
redis-1 | 1:C 01 Mar 2025 10:34:57.876 # Redis version=6.2.17, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1 | 1:C 01 Mar 2025 10:34:57.876 # Configuration loaded
redis-1 | 1:M 01 Mar 2025 10:34:57.877 * monotonic clock: POSIX clock_gettime
redis-1 | 1:M 01 Mar 2025 10:34:57.877 * Running mode=standalone, port=6379.
redis-1 | 1:M 01 Mar 2025 10:34:57.877 # Server initialized
redis-1 | 1:M 01 Mar 2025 10:34:57.877 * Ready to accept connections
ssrf_proxy-1 | 2025/03/01 10:35:06| Service Name: squid
sandbox-1 | 2025/03/01 10:34:55 setup.go:33: [INFO]initializing python runner environment...
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: using the "epoll" event method
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: nginx/1.27.4
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: built by gcc 12.2.0 (Debian 12.2.0-14)
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: OS: Linux 5.15.167.4-microsoft-standard-WSL2
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker processes
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 19
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 20
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 21
sandbox-1 | 2025/03/01 10:34:55 config.go:129: [INFO]network has been enabled
sandbox-1 | 2025/03/01 10:34:55 config.go:145: [INFO]using https proxy: http://ssrf_proxy:3128
sandbox-1 | 2025/03/01 10:34:55 config.go:154: [INFO]using http proxy: http://ssrf_proxy:3128
sandbox-1 | 2025/03/01 10:34:55 server.go:20: [INFO]config init success
sandbox-1 | 2025/03/01 10:34:55 server.go:26: [INFO]runner dependencies init success
sandbox-1 | 2025/03/01 10:34:55 cocrrent.go:31: [INFO]setting max requests to 50
sandbox-1 | 2025/03/01 10:34:55 cocrrent.go:13: [INFO]setting max workers to 4
sandbox-1 | 2025/03/01 10:34:55 server.go:47: [INFO]installing python dependencies...
sandbox-1 | 2025/03/01 10:34:55 server.go:53: [INFO]python dependencies installed
sandbox-1 | 2025/03/01 10:34:55 server.go:55: [INFO]initializing python dependencies sandbox...
sandbox-1 | [GIN] 2025/03/01 - 10:35:26 | 200 | 18.658µs | ::1 | GET "/health"
ssrf_proxy-1 | 2025/03/01 10:35:06| Process ID 45
ssrf_proxy-1 | 2025/03/01 10:35:06| Process Roles: master worker
ssrf_proxy-1 | 2025/03/01 10:35:06| With 1024 file descriptors available
ssrf_proxy-1 | 2025/03/01 10:35:06| Initializing IP Cache...
ssrf_proxy-1 | 2025/03/01 10:35:06| DNS IPv6 socket created at [::], FD 8
ssrf_proxy-1 | 2025/03/01 10:35:06| DNS IPv4 socket created at 0.0.0.0, FD 9
ssrf_proxy-1 | 2025/03/01 10:35:06| Adding nameserver 127.0.0.11 from /etc/resolv.conf
ssrf_proxy-1 | 2025/03/01 10:35:06| Adding ndots 1 from /etc/resolv.conf
ssrf_proxy-1 | 2025/03/01 10:35:06| Logfile: opening log daemon:/var/log/squid/access.log
ssrf_proxy-1 | 2025/03/01 10:35:06| Logfile Daemon: opening log /var/log/squid/access.log
ssrf_proxy-1 | 2025/03/01 10:35:06| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
ssrf_proxy-1 | 2025/03/01 10:35:06| Store logging disabled
ssrf_proxy-1 | 2025/03/01 10:35:06| Swap maxSize 0 + 262144 KB, estimated 20164 objects
ssrf_proxy-1 | 2025/03/01 10:35:06| Target number of buckets: 1008
ssrf_proxy-1 | 2025/03/01 10:35:06| Using 8192 Store buckets
ssrf_proxy-1 | 2025/03/01 10:35:06| Max Mem size: 262144 KB
ssrf_proxy-1 | 2025/03/01 10:35:06| Max Swap size: 0 KB
ssrf_proxy-1 | 2025/03/01 10:35:06| Using Least Load store dir selection
ssrf_proxy-1 | 2025/03/01 10:35:06| Set Current Directory to /var/spool/squid
ssrf_proxy-1 | 2025/03/01 10:35:06| Finished loading MIME types and icons.
ssrf_proxy-1 | 2025/03/01 10:35:06| HTCP Disabled.
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 22
api-1 | Running migrations
api-1 | 2025-03-01 10:35:13.052 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 32 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
api-1 | 2025-03-01 10:35:13.052 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads.
api-1 | /app/api/.venv/lib/python3.12/site-packages/opik/evaluation/metrics/heuristics/regex_match.py:8: SyntaxWarning: invalid escape sequence '\d'
api-1 | """
ssrf_proxy-1 | 2025/03/01 10:35:06| Pinger socket opened on FD 15
ssrf_proxy-1 | 2025/03/01 10:35:06| Squid plugin modules loaded: 0
ssrf_proxy-1 | 2025/03/01 10:35:06| Adaptation support is off.
ssrf_proxy-1 | 2025/03/01 10:35:06| Accepting HTTP Socket connections at conn3 local=[::]:3128 remote=[::] FD 12 flags=9
ssrf_proxy-1 | listening port: 3128
ssrf_proxy-1 | 2025/03/01 10:35:06| Accepting reverse-proxy HTTP Socket connections at conn5 local=[::]:8194 remote=[::] FD 13 flags=9
ssrf_proxy-1 | listening port: 8194
ssrf_proxy-1 | 2025/03/01 10:35:06| Configuring Parent sandbox
ssrf_proxy-1 | 2025/03/01 10:35:06 pinger| Initialising ICMP pinger ...
ssrf_proxy-1 | 2025/03/01 10:35:06 pinger| ICMP socket opened.
ssrf_proxy-1 | 2025/03/01 10:35:06 pinger| ICMPv6 socket opened
ssrf_proxy-1 | 2025/03/01 10:35:07| storeLateRelease: released 0 objects
api-1 | 2025-03-01 10:35:17.190 INFO [MainThread] [_client.py:1038] - HTTP Request: GET https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json "HTTP/1.1 200 OK"
api-1 | Preparing database migration...
api-1 | Starting database migration.
api-1 | ERROR [root] Failed to execute database migration
api-1 | Traceback (most recent call last):
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 23
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 24
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 25
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 26
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 27
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 28
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 29
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 30
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 31
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 32
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 33
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 34
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 35
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 36
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 37
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 38
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 39
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 40
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 41
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 42
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 43
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 44
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 45
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 46
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 47
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 48
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 49
nginx-1 | 2025/03/01 10:35:15 [notice] 10#10: start worker process 50
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
api-1 | self._dbapi_connection = engine.raw_connection()
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection
api-1 | return self.pool.connect()
api-1 | ^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
api-1 | return _ConnectionFairy._checkout(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
api-1 | fairy = _ConnectionRecord.checkout(pool)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
api-1 | rec = pool._do_get()
api-1 | ^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
api-1 | with util.safe_reraise():
api-1 | ^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
api-1 | raise exc_value.with_traceback(exc_tb)
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
api-1 | return self._create_connection()
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
api-1 | return _ConnectionRecord(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
api-1 | self.__connect()
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
api-1 | with util.safe_reraise():
api-1 | ^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
api-1 | raise exc_value.with_traceback(exc_tb)
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
api-1 | self.dbapi_connection = connection = pool._invoke_creator(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 643, in connect
api-1 | return dialect.connect(*cargs, **cparams)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 621, in connect
api-1 | return self.loaded_dbapi.connect(*cargs, **cparams)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect
api-1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/psycogreen/gevent.py", line 32, in gevent_wait_callback
api-1 | state = conn.poll()
api-1 | ^^^^^^^^^^^
api-1 | psycopg2.OperationalError: Connection refused
api-1 | Is the server running on that host and accepting TCP/IP connections?
api-1 |
api-1 |
api-1 | The above exception was the direct cause of the following exception:
api-1 |
api-1 | Traceback (most recent call last):
api-1 | File "/app/api/commands.py", line 594, in upgrade_db
api-1 | flask_migrate.upgrade()
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped
api-1 | f(*args, **kwargs)
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade
api-1 | command.upgrade(config, revision, sql=sql, tag=tag)
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 406, in upgrade
api-1 | script.run_env()
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 586, in run_env
api-1 | util.load_python_file(self.dir, "env.py")
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
api-1 | module = load_module_py(module_id, path)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
api-1 | spec.loader.exec_module(module) # type: ignore
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "<frozen importlib._bootstrap_external>", line 999, in exec_module
api-1 | File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
api-1 | File "/app/api/migrations/env.py", line 109, in <module>
api-1 | run_migrations_online()
api-1 | File "/app/api/migrations/env.py", line 93, in run_migrations_online
api-1 | with connectable.connect() as connection:
api-1 | ^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3278, in connect
api-1 | return self._connection_cls(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 148, in __init__
api-1 | Connection._handle_dbapi_exception_noconnection(
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2442, in _handle_dbapi_exception_noconnection
api-1 | raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
api-1 | self._dbapi_connection = engine.raw_connection()
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection
api-1 | return self.pool.connect()
api-1 | ^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
api-1 | return _ConnectionFairy._checkout(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
api-1 | fairy = _ConnectionRecord.checkout(pool)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
api-1 | rec = pool._do_get()
api-1 | ^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
api-1 | with util.safe_reraise():
api-1 | ^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
api-1 | raise exc_value.with_traceback(exc_tb)
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
api-1 | return self._create_connection()
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
api-1 | return _ConnectionRecord(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
api-1 | self.__connect()
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
api-1 | with util.safe_reraise():
api-1 | ^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
api-1 | raise exc_value.with_traceback(exc_tb)
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
api-1 | self.dbapi_connection = connection = pool._invoke_creator(self)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 643, in connect
api-1 | return dialect.connect(*cargs, **cparams)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 621, in connect
api-1 | return self.loaded_dbapi.connect(*cargs, **cparams)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect
api-1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/psycogreen/gevent.py", line 32, in gevent_wait_callback
api-1 | state = conn.poll()
api-1 | ^^^^^^^^^^^
api-1 | sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) Connection refused
api-1 | Is the server running on that host and accepting TCP/IP connections?
api-1 |
api-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8)
api-1 | [2025-03-01 10:35:25 +0000] [1] [INFO] Starting gunicorn 23.0.0
api-1 | [2025-03-01 10:35:25 +0000] [1] [INFO] Listening at: http://0.0.0.0:5001 (1)
api-1 | [2025-03-01 10:35:25 +0000] [1] [INFO] Using worker: gevent
api-1 | [2025-03-01 10:35:25 +0000] [60] [INFO] Booting worker with pid: 60
api-1 | 2025-03-01 10:35:27.184 INFO [MainThread] [utils.py:149] - Note: NumExpr detected 32 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 16.
api-1 | 2025-03-01 10:35:27.185 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 16 threads.
api-1 | 2025-03-01 10:35:29.331 INFO [MainThread] [_client.py:1038] - HTTP Request: GET https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json "HTTP/1.1 200 OK"
plugin_daemon-1 | 2025/03/01 10:35:02 pool.go:32: [INFO]init routine pool, size: 10000
plugin_daemon-1 |
plugin_daemon-1 | 2025/03/01 10:35:02 /app/internal/db/init.go:17
plugin_daemon-1 | [error] failed to initialize database, got error failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | 2025/03/01 10:35:02 init.go:141: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | panic: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)%!(EXTRA *pgconn.ConnectError=failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused))
plugin_daemon-1 |
plugin_daemon-1 | goroutine 1 [running]:
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.writeLog({0x15f6a9b, 0x5}, {0x16247ca?, 0x2?}, 0x1, {0xc00063fd00, 0x1, 0x1})
plugin_daemon-1 | /app/internal/utils/log/log.go:40 +0x326
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.Panic(...)
plugin_daemon-1 | /app/internal/utils/log/log.go:66
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/db.Init(0x2710?)
plugin_daemon-1 | /app/internal/db/init.go:141 +0xbb
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/server.(*App).Run(0xc0005aa1e0, 0xc0002fe588)
plugin_daemon-1 | /app/internal/server/server.go:55 +0xd2
plugin_daemon-1 | main.main()
plugin_daemon-1 | /app/cmd/server/main.go:28 +0xff
plugin_daemon-1 | 2025/03/01 10:35:14 pool.go:32: [INFO]init routine pool, size: 10000
plugin_daemon-1 |
plugin_daemon-1 | 2025/03/01 10:35:14 /app/internal/db/init.go:17
plugin_daemon-1 | [error] failed to initialize database, got error failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | 2025/03/01 10:35:14 init.go:141: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | panic: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)%!(EXTRA *pgconn.ConnectError=failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused))
plugin_daemon-1 |
plugin_daemon-1 | goroutine 1 [running]:
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.writeLog({0x15f6a9b, 0x5}, {0x16247ca?, 0x2?}, 0x1, {0xc00073fd00, 0x1, 0x1})
plugin_daemon-1 | /app/internal/utils/log/log.go:40 +0x326
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.Panic(...)
plugin_daemon-1 | /app/internal/utils/log/log.go:66
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/db.Init(0x2710?)
plugin_daemon-1 | /app/internal/db/init.go:141 +0xbb
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/server.(*App).Run(0xc0002020f0, 0xc00031b8c8)
plugin_daemon-1 | /app/internal/server/server.go:55 +0xd2
plugin_daemon-1 | main.main()
plugin_daemon-1 | /app/cmd/server/main.go:28 +0xff
plugin_daemon-1 | 2025/03/01 10:35:44 pool.go:32: [INFO]init routine pool, size: 10000
plugin_daemon-1 |
plugin_daemon-1 | 2025/03/01 10:35:44 /app/internal/db/init.go:17
plugin_daemon-1 | [error] failed to initialize database, got error failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | 2025/03/01 10:35:44 init.go:141: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | panic: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)%!(EXTRA *pgconn.ConnectError=failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused))
plugin_daemon-1 |
plugin_daemon-1 | goroutine 1 [running]:
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.writeLog({0x15f6a9b, 0x5}, {0x16247ca?, 0x2?}, 0x1, {0xc00063fd00, 0x1, 0x1})
plugin_daemon-1 | /app/internal/utils/log/log.go:40 +0x326
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.Panic(...)
plugin_daemon-1 | /app/internal/utils/log/log.go:66
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/db.Init(0x2710?)
plugin_daemon-1 | /app/internal/db/init.go:141 +0xbb
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/server.(*App).Run(0xc0005b2198, 0xc00033fb88)
plugin_daemon-1 | /app/internal/server/server.go:55 +0xd2
plugin_daemon-1 | main.main()
plugin_daemon-1 | /app/cmd/server/main.go:28 +0xff
plugin_daemon-1 | 2025/03/01 10:35:53 pool.go:32: [INFO]init routine pool, size: 10000
plugin_daemon-1 |
plugin_daemon-1 | 2025/03/01 10:35:53 /app/internal/db/init.go:17
plugin_daemon-1 | [error] failed to initialize database, got error failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | 2025/03/01 10:35:53 init.go:141: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
plugin_daemon-1 | panic: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)%!(EXTRA *pgconn.ConnectError=failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.19.0.3:5432: connect: connection refused))
plugin_daemon-1 |
plugin_daemon-1 | goroutine 1 [running]:
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.writeLog({0x15f6a9b, 0x5}, {0x16247ca?, 0x2?}, 0x1, {0xc0006bfd00, 0x1, 0x1})
plugin_daemon-1 | /app/internal/utils/log/log.go:40 +0x326
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/utils/log.Panic(...)
plugin_daemon-1 | /app/internal/utils/log/log.go:66
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/db.Init(0x2710?)
plugin_daemon-1 | /app/internal/db/init.go:141 +0xbb
plugin_daemon-1 | github.com/langgenius/dify-plugin-daemon/internal/server.(*App).Run(0xc000116108, 0xc0002998c8)
plugin_daemon-1 | /app/internal/server/server.go:55 +0xd2
plugin_daemon-1 | main.main()
plugin_daemon-1 | /app/cmd/server/main.go:28 +0xff
To resolve the "Connection refused" error when trying to connect to the PostgreSQL database in a self-hosted Dify setup using Docker, you should consider downgrading to version 0.15.3 instead of using 1.0.0-beta1. This error often occurs due to database initialization issues, which cause a connection failure to the PostgreSQL database. Before switching versions, delete any existing Dify Docker images to ensure a clean installation. This approach has been confirmed to resolve both the database connection error and the PluginDaemonUnauthorizedError [1][2].
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
i slove this problem,you can use this to remove the postgresql on your computer
sudo apt purge postgresql postgresql-* sudo apt autoremove sudo rm -rf /var/lib/postgresql/
then Next, start normally
i slove this problem,you can use this to remove the postgresql on your computer
sudo apt purge postgresql postgresql-* sudo apt autoremove sudo rm -rf /var/lib/postgresql/then Next, start normally
still not work ,this can not Create a knowledge base
I'm facing the same error and would like to continue using v1.0.0 without having to downgrade if possible. I haven't been able to solve it on my own, so I really hope a solution can be found...
I try to change the db config in .env file to fix it. But it still not work.
i got this error too
+1
+1
+1, i also confirm container's env DB_HOST and others is right. im not sure why env is not effect
I solved the problem by upgrade docker-engin to docker-ce newest version.
+1
+1
I solved the problem by upgrade docker-engin to docker-ce newest version.
How to upgrade?
+1
+1
I solved this by turning off the proxy
+1
I have opened a PR to fix this.
If you still face the problem after adding the DB as dependency in docker compose file:
Run docker-compose up -d in docker directory to apply the changes.
I have opened a PR to fix this.
I have updated the docker-compose.yaml and the issue still exists:
I have still encountered this issue.
From my testing, the error message
host=db user=postgres database=postgres: dial error (dial tcp 172.19.0.3:5432: connect: connection refused)
host is corresponding to DB_HOST in .env
user is corresponding to DB_USERNAME in .env
database seems to be fixed
the port 5432 might correspond to DB_PORT or EXPOSE_DB_PORT or other *_PORT in .env, I am not sure.
I guess the database should be agree with DB_DATABASE.
I was able to solve this setting DB_SSL_MODE=require in the .env file for the container running the plugin daemon
I was able to solve this setting
DB_SSL_MODE=requirein the .env file for the container running the plugin daemon
Thanks a lot! It worked for my case.
I was able to solve this setting
DB_SSL_MODE=requirein the .env file for the container running the plugin daemon
Where should a add that? I added into .env but it didn't work
If you have VPN turned on, try turn it off and restart Docker and Dify.
I still the problem. Nothing discussed above worked for me :(
With ripgrep, I find a possible problem that might link to this bug.
analyticdb_vector_sql.py does have fixed "postgres" as default database, and it is not changable for any setting.
On the other hand, a similar file pgvector.py is in the same structure, but it is able to handle with database specified in a .env file.