Ara*_*ian 21 postgresql ubuntu port
所以我正在使用AWS使用EC2,我正在尝试为Postgresql打开一个端口.在AWS中我已经打开它:
TCP
Port (Service) Source Action
0 - 65535 sg-92aadda2 (default) Delete
22 (SSH) 0.0.0.0/0 Delete
80 (HTTP) 0.0.0.0/0 Delete
5432 0.0.0.0/0 Delete
Run Code Online (Sandbox Code Playgroud)
当我做netstat时,看起来好像端口在监听:
# netstat -an | grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
Run Code Online (Sandbox Code Playgroud)
当我做localhost nmap时,我得到以下内容:
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000010s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
5432/tcp open postgresql
Run Code Online (Sandbox Code Playgroud)
这就是乐趣开始的地方.当我从备用主机执行nmap时,我得到以下内容:
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
5432/tcp closed postgresql
Run Code Online (Sandbox Code Playgroud)
我也查看了我的iptables,看看我是否遗漏了什么,但iptables看起来是空的(这应该意味着他们并没有真正做多少)
$ iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql
ACCEPT icmp -- anywhere anywhere
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
DROP all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DROP all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Run Code Online (Sandbox Code Playgroud)
我错过了什么因为我似乎无法弄清楚如何访问IP.每当我尝试时,我都会收到以下错误:
Is the server running on host "xx.xx.xx.xx" and accepting TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
我如何制作它以便我可以打开端口以便外部服务器可以访问它?在此先感谢=)Lemme知道您是否需要任何其他数据.
编辑:如下所述,我测试了telnet,我能够远程登录到localhost,但是当我从外面尝试时,我得到:
$ telnet xx.xx.xx.xx 5432
Trying xx.xx.xx.xx...
telnet: Unable to connect to remote host: Connection refused
Run Code Online (Sandbox Code Playgroud)
此外,我仔细检查,我能够正确telnet到ssh:
$ telnet xx.xx.xx.xx 22
Trying xx.xx.xx.xx...
Connected to xx.xx.xx.xx.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
Run Code Online (Sandbox Code Playgroud)
TeT*_*TeT 38
编辑/etc/postgresql/<version>/main/postgresql.conf并设置listen_addresses为您的传出界面或全部.重启postgresql : sudo service postgresql restart.
小智 30
It works for me the last method (thks Julio):
Edit: postgresql.conf
sudo nano /etc/postgresql/9.3/main/postgresql.conf
Enable or add:
listen_addresses = '*'
Restart the database engine:
sudo service postgresql restart
Besides, you can check the file: pg_hba.conf
sudo nano /etc/postgresql/9.3/main/pg_hba.conf
And add your network or host address:
host all all 192.168.1.0/24 md5
小智 10
如果你已经编辑了postgresql.conf和 main/pg_hba.conf并且仍然有问题,请尝试
sudo ufw allow 5432/tcp
Run Code Online (Sandbox Code Playgroud)
解锁 psql 端口
| 归档时间: |
|
| 查看次数: |
50059 次 |
| 最近记录: |