我在 Cloud Sql 上创建了一个单区 postgres db 实例,我正在尝试通过 cloud sql 代理进行连接。
/cloud_sql_proxy -instances=<PROJECT_ID>:us-central1:staging=tcp:5432 -credential_file=./<SERVICE_ACCOUNT_KEY_FILE>
这运行良好。但是当我在命令下运行时,
psql "host=127.0.0.1 sslmode=disable dbname=postgres user=postgres"
代理显示此错误:
2019/11/14 15:20:10 using credential file for authentication; email=<SERVICE_ACCOUNT_EMAIL>
2019/11/14 15:20:13 Listening on 127.0.0.1:5432 for <PROJECT_ID>:us-central1:staging
2019/11/14 15:20:13 Ready for new connections
2019/11/14 15:20:34 New connection for "<PROJECT_ID>:us-central1:staging"
2019/11/14 15:22:45 couldn't connect to "<PROJECT_ID>:us-central1:staging": dial tcp 34.70.245.249:3307: connect: connection timed out
为什么会这样?我是从我当地做的。