问题:

postgresql部署在linux上,在自己电脑上使用pgadmin连接出现could not connect to server错误

问题分析:

出现上述原因有3种情况

1.linux上的防火墙没有关闭

2.postgresql服务没有监听对应的ip与端口

3.没有设置认证规则

解决步骤:

1.查看是否postgresql服务没有监听对应的ip与端口

netstat -anp|grep postmast

下图第一个为127..0.0.1:5432代表postgresql监听127.0.0.1访问地址5432端口的tcp请求,这个是错误的应该127.0.0.0代表本机地址,其他远程将不能被监听到。

第二个为正确设置后的地址0.0.0.0代表任意地址。

2.如果出现上述问题,请设置postgresql.conf

vi /var/lib/pgsql/11/data/postgresql.conf

postgresql文件的路径不同版本会有不同,但是基本在此路径下,如果找不到可以使用以下命令

find / -name postgresql.conf

3.修改postgresql.conf中的listen_addresses地址

修改命令在此不做详细说明,自行查看linux命令,注意一定要去掉“#”注释,网上很多博客不写,会误以为不去掉#配置也能生效

4.添加任意地址的认证

vi /var/lib/pgsql/11/data/pg_hba.conf

在最后一行加入“host all all 0.0.0.0/0 md5”,结果如下:

5.关闭防火墙(或者添加放行端口和协议)

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service

6.重启服务

systemctl restart postgresql-11.service

 总结

主要是设置防火墙,设置两个文件

postgresql could not connect to server的更多相关文章

  1. 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

    错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...

  2. postgresql connection failure:SQLSTATE[08006] [7] could not connect to server: Permission denied Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

    PHP 程序无法连接到 CentOS 上的PostgreSQL,但是在 CentOS 服务器上却能正常运行 psql, 操作如下:多次重启 PG 数据库后发现 CGI 脚本无法连接数据库,但是可以使用 ...

  3. 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

    错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...

  4. “psql: could not connect to server: Connection refused” Error when connecting to remote database

    问题: I am trying to connect to a postgres database installed in a remote server using the following c ...

  5. could not connect to server: Connection refused (0x0000274D/10061)

    Oracle Linux 6.8 PostgreSQL Server IP: 192.168.10.220 Windows 7 x64 pgAdmin Custom Port IP: 192.168. ...

  6. docker 踩坑笔记之 psql: could not connect to server

    最近在用docker跑rails,也遇到了一些坑,这里记录一下. 首先build项目: docker-compose build 然后就开始报错了: psql: could not connect t ...

  7. psql: could not connect to server: No such file or directory

    postgresql报错: psql: could not connect to server: No such file or directory         Is the server run ...

  8. SSH登录之后运行命令报错的解决办法-- Failed to connect to Mir: Failed to connect to server socket: No such file or directory

    问题描述: Failed to connect to Mir: Failed to connect to server socket: No such file or directory 解决方案: ...

  9. LoadRunner执行过程报错“Failed to connect to server "xxx.xxx.xxx.xxx:xx":[10060] connetion time out”

    执行性能测试过程中,LR报错: Action.c(6):Error -27796: Failed to connect to server "xxx.xxx.xxx.xxx:xx" ...

随机推荐

  1. 【Transact-SQL】让人快遗忘的游标

    原文:[Transact-SQL]让人快遗忘的游标 最初学SQL Server的时候,当学到游标的时候,突然有了一种亲切感,因为这种通过一个while循环,一条一条的处理数据的方式,很像学过的过程式语 ...

  2. JS OOP -01 面向对象的基础

    JS面向对象的基础: 1.用定义函数的方式定义类 2.用new操作符获得一个类的实例 3.使用 [ ] 引用对象的属性和方法 4.动态添加,修改,删除对象的属性和方法 5.使用 { } 语法创建无类型 ...

  3. Python练习_初识函数_day9

    1. 1.作业 1,写函数,检查获取传入列表或元组对象的所有奇数位索引对应的元素,并将其作为新列表返回给调用者. 2,写函数,判断用户传入的对象(字符串.列表.元组)长度是否大于5. 3,写函数,检查 ...

  4. Java基础加强-类加载器

    /*类加载器*/ 把.class文件从硬盘上加载出来,将类的字节码(二进制)加载到内存中 /*类加载器及其委托机制*/ Java虚拟机中可以安装多个类加载器(可以自己编写),系统默认三个主要类加载器, ...

  5. ASE19团队项目beta阶段Backend组 scrum5 记录

    本次会议于12月11日,19:30在微软北京西二号楼sky garden召开,持续10分钟. 与会人员:Zhikai Chen, Lihao Ran, Xin Kang 请假人员:Hao Wang 每 ...

  6. Mongodb 的ORM框架 Morphia 注解 之 @Reference

    public class BlogEntry { private String title; private Date publishDate; private String body; privat ...

  7. linux 基础9-账号与身份管理

    1. linux的账号与群组 1.1 账户名称:/etc/passwd: head -n 5 /etc/password #取前5行 账号名称,对应UID 密码,早期是在这里,后来转到了/etc/sh ...

  8. OpenGL学习脚印: uniform blocks在着色器中的使用 转自https://blog.csdn.net/wangdingqiaoit/article/details/52717963

    写在前面 目前,我们在着色器中要传递多个uniform变量时,总是使用多个uniform,然后在主程序中设置这些变量的值:同时如果要在多个shader之间共享变量,例如投影矩阵projection和视 ...

  9. 正则表达式匹配IP地址

    '''首先分析ip地址的特征:255.255.255.255,前三位的数字处理基本一致 1位: 0-9              \d2位:10-99         [1-9]\d3位:100-19 ...

  10. #Python绘制 文本进度条,带刷新、时间暂缓的

    #Python绘制 文本进度条,带刷新.时间暂缓的 #文本进度条 import time as T st=T.perf_counter() print('-'*6,'执行开始','-'*6) maxx ...