hi all, how can I connect to GCP SQL PostgreSQL? t...
# orm-help
y
hi all, how can I connect to GCP SQL PostgreSQL? this string doesn’t work:
Copy code
DATABASE_URL="postgresql://${GCP_SQL_USER}:${GCP_SQL_PASSWORD}@${GCP_SQL_HOST}:5432/${GCP_SQL_DB}
1
t
How do you connect your server to cloud sql? If you use unix socket, format is
Copy code
postgresql://${db_user_name}:${db_password}@localhost/${db_name}?${socket_path}.
If you use tcp
Copy code
"postgresql://${user}:{password}@${host}:${port}/${db_ame}?schema=public"
. Furthermore if you don’t open port (it’s recommended), your client server needs run cloud_sql_proxy as daemon. Refer https://cloud.google.com/sql/docs/postgres/connect-admin-proxy?hl=en In rare case but, it happen to me, random generated password includes forbidden character like ‘$’. It translate shell variable after letter thus can cause break access data url. If you can’t connect
psql $DATABASE_URL
, it may happen.
I expect you connect tcp as you comment. I suspect you don’t specify schema or run cloud_sql_proxy.
y
hi @Takeo Kusama, thanks for your reply! it seems having
:
character at the begging of password is prohibited. after I changed user password, I was able to connect. Thank you!
👍 1
e
what an edge case, avoid using
:
to start your password because the linter checks for
:
to separate a username from the password in the connection string.