Nocobase 连不上外网远程数据库

* 描述问题

就是使用docker环境配置了,本机以外的数据库然后发现,我使用Navicat 等工具连接是正常的,但是使用nocobase是连不上,我测试之间的网络是通

* 运行环境

  • NocoBase 版本:1.9.0-alpha.2
  • 数据库种类与版本: image: postgres:15
  • 操作系统: Ubuntu Windows
    -浏览器及版本
  • 部署方式:docker-compose
  • Docker 镜像版本:1.9.0-alpha.2
  • NodeJS 版本:

如何重现

预期行为

截图

日志

root@lavm-ka9wkt4xbk:/xp/www/.com# docker-compose up -d
Creating network “startuptdcktzcom_nocobase” with driver “bridge”
Creating startuptdcktzcom_app_1 … done
root@lavm-ka9wkt4xbk:/xp/www/.com# docker logs --tail=100 -f nocobase_app_1
cat: /app/commit_hash.txt: No such file or directory
COMMIT_HASH:
copying…
yarn run v1.22.22
$ nocobase create-nginx-conf
Done in 0.43s.
yarn run v1.22.22
$ nocobase generate-instance-id
Generating InstanceID…
[Error: Get environment error: GenericFailure, GenericFailure, Get postgres configuration error: error connecting to server: Connection timed out (os error 110)] {
code: ‘GenericFailure’
}
Done in 130.38s.
nginx started
yarn run v1.22.22
$ nocobase start --quickstart
$ nocobase pkg download-pro
2025-07-17T22:44:08: PM2 log: Launching in no daemon mode
2025-07-17T22:44:08: PM2 log: App [index:0] starting in -fork mode-
2025-07-17T22:44:08: PM2 log: App [index:0] online
Gateway IPC Server running at /root/.nocobase/gateway.sock
Gateway HTTP Server running at http://0.0.0.0:13000/
{“level”:“info”,“message”:“add app main into supervisor”,“meta”:{},“module”:“application”,“submodule”:“supervisor”,“method”:“addApp”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:44:11”}
{“level”:“warn”,“message”:“attempt 1/9: Unable to connect to the database: connect ETIMEDOUT 124.xxx.xxx.xxx:5432”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:46:22”}
{“level”:“warn”,“message”:“will retry in 50ms…”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:46:22”}
{“level”:“warn”,“message”:“attempt 2/9: Unable to connect to the database: connect ETIMEDOUT 124.xxx.xxx.xxx:5432”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:48:33”}
{“level”:“warn”,“message”:“will retry in 100ms…”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:48:33”}
{“level”:“warn”,“message”:“attempt 3/9: Unable to connect to the database: connect ETIMEDOUT 124.xxx.xxx.xxx:5432”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:50:44”}
{“level”:“warn”,“message”:“will retry in 200ms…”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:50:44”}
{“level”:“warn”,“message”:“attempt 4/9: Unable to connect to the database: connect ETIMEDOUT 124.xxx.xxx.xxx:5432”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:52:55”}
{“level”:“warn”,“message”:“will retry in 400ms…”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:52:55”}
{“level”:“warn”,“message”:“attempt 5/9: Unable to connect to the database: connect ETIMEDOUT 124.xxx.xxx.xxx:5432”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:55:06”}
{“level”:“warn”,“message”:“will retry in 800ms…”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:55:06”}
{“level”:“warn”,“message”:“attempt 6/9: Unable to connect to the database: connect ETIMEDOUT 124.xxx.xxx.xxx:5432”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:57:17”}
{“level”:“warn”,“message”:“will retry in 1600ms…”,“meta”:{},“module”:“database”,“submodule”:“”,“method”:“auth”,“app”:“main”,“reqId”:“21507747-fd7d-4c15-9746-4ce74db1e42a”,“dataSourceKey”:“main”,“timestamp”:“2025-07-17 22:57:17”}
new client connected oNx7FdxQ8U7in9eq6QRen
client tags: app#main

nocobase部署:

version: “3”
networks:
nocobase:
driver: bridge
services:
app:
image: nocobase/nocobase:1.9.0-alpha.2
networks:
- nocobase
environment:
- APP_KEY=your-secret-key # Replace it with your own app key
- ENCRYPTION_FIELD_KEY=your-secret-key # Replace it with your own app key
- DB_DIALECT=postgres
- DB_HOST=124.XXX.XXX.XXX
- DB_DATABASE=nocobase_crm
- DB_USER=postgres
- DB_PASSWORD=postgres
volumes:
- ./storage:/app/nocobase/storage
ports:
- “13000:80”
init: true

数据库部署:

db:
container_name: dify_pg
image: postgres:15-alpine
restart: always
ports:
- “${DB_PORT:-5432}:5432”
environment:
PGUSER: ${PGUSER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-difyai123456}
POSTGRES_DB: ${POSTGRES_DB:-dify}
PGDATA: ${PGDATA:-/var/lib/postgresql/data/pgdata}
command: >
postgres -c ‘max_connections=${POSTGRES_MAX_CONNECTIONS:-100}’
-c ‘shared_buffers=${POSTGRES_SHARED_BUFFERS:-128MB}’
-c ‘work_mem=${POSTGRES_WORK_MEM:-4MB}’
-c ‘maintenance_work_mem=${POSTGRES_MAINTENANCE_WORK_MEM:-64MB}’
-c ‘effective_cache_size=${POSTGRES_EFFECTIVE_CACHE_SIZE:-4096MB}’
volumes:
- ./volumes/db/data:/var/lib/postgresql/data
healthcheck:
test: [ ‘CMD’, ‘pg_isready’, ‘-h’, ‘db’, ‘-U’, ‘${PGUSER:-postgres}’, ‘-d’, ‘${POSTGRES_DB:-dify}’ ]
interval: 1s
timeout: 3s
retries: 60

这种问题还需要你们自己排查。