我在 Cloud SQL 上创建了单区域的 PostgreSQL 数据库实例,现在我正在尝试使用 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
为什么会发生这种情况? 我是从本地进行操作。