简体   繁体   English

无法将服务器上的 postgres 连接到我本地的 postico

[英]can't connect postgres on the server to postico on my local

when I connect postgres on the server to postico on my local I get this error当我将服务器上的 postgres 连接到本地的 postico 时,出现此错误

could not connect to server: Operation timed out
Is the server running on host "http://159.65.65.203/" (92.242.140.2) and accepting
TCP/IP connections on port 5432?

I could not find anywhere postgresql.conf and pg_hba.conf files, so i created the files, as you see in the below image我在任何地方都找不到 postgresql.conf 和 pg_hba.conf 文件,所以我创建了这些文件,如下图所示

在此处输入图像描述

I found this explanation but still does not solve my issue我找到了这个解释,但仍然没有解决我的问题

Ubuntu does not use the standard pg_ctl for postgreSQL. Instead, it 
uses pg_ctlcluster.
That in turn controls the different PostgreSQL clusters. When you do 
an install of a new cluster, pg_ctlcluster is smart enough to put
postgresql.conf & pg_hba.conf into separate dirs.
So to be specific, /usr/lib/tmpfiles.d/postgresql.conf is just a tmp 
file that you can ingnore, /etc/postgresql/9.4/main/postgresql.conf is 
the original version for the 9.4 cluster and
/var/lib/postgresql/9.4/main/postgresql.auto.conf is the actual, live
version of the 9.4 cluster that you need to change to affect the 9.4
cluster. Likewise for the pg_hba.conf.
reference https://www.postgresql.org/message- 
id/CANu8FiygR5CdeqRTiE0YM+BQk6aK+qZyw2frH_FWV27J1exong@mail.gmail.com

here how i configured postgresql.conf这里我如何配置 postgresql.conf

port=5432
listen_addresses='*'

here how i configured pg_hba.conf这里我是如何配置 pg_hba.conf

 host    all             all              0.0.0.0/0                       md5
 host    all             all              ::/0                            md5

when i run当我跑步时

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program 
name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      
29761/postgres
tcp6       0      0 :::22                   :::*                    LISTEN      -

Clearly 5432 is not open for all connections.显然 5432 并非对所有连接都开放。 when i make an api call using postman seems to work.当我使用 postman 进行 api 调用时似乎有效。 I use mac currently firewall not on, i have my server on digitalocean use Ubuntu 16.04.6 (LTS) x64.我目前使用的 mac 防火墙没有打开,我的服务器在 digitalocean 上使用 Ubuntu 16.04.6 (LTS) x64。

This is the path of postgres files这是 postgres 文件的路径

postgres@borroupapi:~/9.5/main$

when i run find / -name postgresql.conf i get this当我运行 find / -name postgresql.conf 我明白了

/usr/lib/tmpfiles.d/postgresql.conf

but i cant find the path as logged in postgres user但我找不到登录 postgres 用户的路径

try this to fix the issue in postgres 9.5 postgresql.conf and pg_hba.conf files are located in试试这个来解决 postgres 9.5 中的问题 postgresql.conf 和 pg_hba.conf 文件位于

/etc/postgresql/9.5/main/

not in不在

/var/lib/postgresql/9.5/main/

you have to login as server root user and run each one of the command and that will give where are the files您必须以服务器 root 用户身份登录并运行每个命令,这将给出文件在哪里

find / -name postgresql.conf

find / -name pg_hba.conf

in my instance when i ran the command i got this在我的例子中,当我运行命令时,我得到了这个

/var/lib/postgresql/9.5/main/postgresql.conf
/etc/postgresql/9.5/main/postgresql.conf
/usr/lib/tmpfiles.d/postgresql.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RoR项目-无法连接到远程Postgres DB服务器 - RoR project - can't connect to remote postgres DB server 无法将我的开发环境连接到新导入的postgres数据库 - Can't connect my development environment to a newly imported postgres database 无法通过套接字连接到本地MySQL服务器。 我想连接到远程数据库 - Can't connect to local MySQL server through socket. I want to connect to REMOTE db 无法使用“ pg” gem连接到postgres? - Can't connect to postgres with 'pg' gem? Rails 3.2-无法连接到本地MySQL - Rails 3.2 - Can't connect to local MySQL Mysql无法通过Amazon EC2上的套接字连接到本地服务器 - Mysql can't connect to local server through socket on Amazon EC2 Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) - Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 运行Rails时无法通过ubuntu中的套接字连接到本地MySQL服务器 - Can't connect to local MySQL server through socket in ubuntu while running rails Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) - Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 在本地Linux安装上连接到Postgres数据库 - Connect to postgres database on local linux install
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM