问题:

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. ASP.NET Core 中的脚本标记帮助程序

    官网地址:https://docs.microsoft.com/zh-cn/aspnet/core/mvc/views/tag-helpers/built-in/script-tag-helper?v ...

  2. gitea configure

    gitea configure app.ini APP_NAME = Gitea: Git with a cup of tea RUN_USER = LSGX RUN_MODE = prod [oau ...

  3. 再谈.NET委托(delegate、Func<>)

    为了演示委托,我们先来定义一个方法:public static bool IsTen(int i){    return i == 10 ? true : false;} 如果要用自定义委托,则需要声 ...

  4. javascript--BOM(browser object model)五大对象

    浏览器对象模型: 作用:访问.控制.修改浏览器,与浏览器进行交互(打开新的窗口.回退历史记录.获取url) BOM与的DOM区别:JS通过BOM与浏览器进行交互.BOM的window对象包含了docu ...

  5. 6.Java集合-LinkedList实现原理及源码分析

    Java中LinkedList的部分源码(本文针对1.7的源码) LinkedList的基本结构 jdk1.7之后,node节点取代了 entry ,带来的变化是,将1.6中的环形结构优化为了直线型链 ...

  6. 【转】5种网络IO模型

    5种网络IO模型(有图,很清楚) IO多路复用—由Redis的IO多路复用yinch Linux中对文件描述符的操作(FD_ZERO.FD_SET.FD_CLR.FD_ISSET

  7. 14_sqoop数据导入

    3.Sqoop的数据导入 “导入工具”导入单个表从RDBMS到HDFS.表中的每一行被视为HDFS的记录.所有记录都存储为文本文件的文 本数据(或者Avro.sequence文件等二进制数据) 3.1 ...

  8. Python基本语法变量

    Python的语法和其它编程语言的语法有所不同,编写Paython程序之前需要对语法有所了解,才能编写规范的Python程序.本篇介绍Python标识符的同时,也讨论了Python变量的声明和赋值.通 ...

  9. linux getpid _getpid()

    getpid是一种函数,功能是取得进程识别码,许多程序利用取到的此值来建立临时文件,以避免临时文件相同带来的问题. 函数功能:取得进程识别码 相关函数:fork,kill,getpid 头文件:旧版本 ...

  10. 好吧,关于nginx

    今天在看关于nginx的文章,自己也动手试了一下. 我是在本地测试的,在IIS上面绑了两个网站,端口号不同.当我把IIS配置好以后,修改了nginx的conf文件. nginx配置: nginx配置好 ...