大网数据广告活动
服务器运维问答

Google cloud VM add pgAdmin geting error Unable to connect to server: timeout expired

· 52CE 我爱测

I am connecting my pgAdmin with the VM of google cloud. first I create VM instances after that the public IP address of VM instances I use pgAdmin hostname and when I try to save than getting an error Unable to connect to server:…

问题原文

原帖链接 · Sarthak tiwari · CC BY-SA 4.0

I am connecting my pgAdmin with the VM of google cloud.

first I create VM instances after that the public IP address of VM instances I use pgAdmin hostname and when I try to save than getting an error Unable to connect to server: timeout expired

已采纳解答

原帖链接 · Serhii Rohoza · CC BY-SA 4.0

Have a look at the community tutorial How to set up PostgreSQL on Compute Engine:

This tutorial shows how to set up PostgreSQL on Google Cloud Platform (GCP) in just a few minutes. Follow this tutorial to configure PostgreSQL on an Ubuntu virtual machine instance on Compute Engine.

If you don't want to install and manage your own PostgreSQL database, Google Cloud SQL provides managed PostgreSQL.

You can also use Cloud Launcher to set up PostgreSQL on Compute Engine with just a few clicks.

You should follow steps below:

  1. Create VM instance.
  2. Install PostgreSQL and use PSQL to complete the setup.
  3. Configure PostgreSQL remote access: 3.1. edit pg_hba.conf:
    • navigate to ip4.me to get the IPv4 address of your local computer;
    • scroll down to the bottom of the file and add the following lines:
      # IPv4 remote connections for the tutorial:
      host    all             all           [YOUR_IPV4_ADDRESS]/32         md5
      
    • replace [YOUR_IPV4_ADDRESS] with the address of your local computer;
    • save the file and exit the editor. 3.2. edit postgresql.conf:
    • scroll down to the line that begins with #listen_addresses = 'localhost';
    • delete the # character to uncomment the line;
    • replace localhost with * (the '*' setting enables Postgres to listen on all IP addresses);
    • save the file and exit the editor;
    • restart the database service.
  4. Set network tag postgresql-server to your VM instance:
    gcloud compute instances add-tags instance-1 --zone=europe-west3-a -- tags=postgresql-server
    
  5. Create new firewall rule to allow incoming connections:
    gcloud compute firewall-rules create postgresql-server-rule-in --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:5432 --target-tags=postgresql-server
    
  6. Connect using pgAdmin:
  • in the Host field, enter external IP address of your VM instance;
  • in the Port field, enter 5432.

As an alternative, you can follow documentation 18.11. Secure TCP/IP Connections with SSH Tunnels:

It is possible to use SSH to encrypt the network connection between clients and a PostgreSQL server. Done properly, this provides an adequately secure network connection, even for non-SSL-capable clients.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-07-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。