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

Port 5432 listening but unreachable after installing Postgres

· 52CE 我爱测

I have an Ubuntu VM, hosted with Microsoft Azure. It was completely blank, and then I installed Postgres using sudo apt-get install postgresql . The version I installed is Ubuntu 10.10-0ubuntu0.18.04.1 . I configured Postgres in …

问题原文

原帖链接 · Reyedy · CC BY-SA 4.0

I have an Ubuntu VM, hosted with Microsoft Azure. It was completely blank, and then I installed Postgres using sudo apt-get install postgresql.

The version I installed is Ubuntu 10.10-0ubuntu0.18.04.1.

I configured Postgres in order to accept remote connections, by following this tutorial:

  • I edited my postgresql.conf file by setting listen_addresses = '*'.
  • I edited my pg_hba.conf file by adding the two following lines:

    host all all 0.0.0.0/0 md5

    host all all ::/0 md5

And I restarted Postgres, and even the whole server for good measure.

When I execute netstat -tln, I obtain the following result:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::5432                 :::*                    LISTEN

My iptables are totally empty, I did not do anything with it after creating the VM.

From another client, I tried to execute sudo -u postgres psql -h [host] -U postgres, and the request times out.

When I execute telnet [host] 5432 from another client, nothing happens until it times out. However, executing telnet [host] 22 works fine, and executing telnet [host] 80 gets me a connexion refused, which I assume means that my host is at least listening on these ports.

What could I be missing here?

已采纳解答

原帖链接 · Smrithin N S · CC BY-SA 4.0

Try switching as postgres user and enter psql on the machine where postgres is installed. This will make sure the installation is correct or wrong.

su - postgres
psql

Check the firewall in Azure console, probably you will have to enable port 5432.

More information about how to open ports on an Azure VM can be found here.

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

资料来源与适用范围

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

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

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