postgresql could not connect to server
问题:
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的更多相关文章
- 问题解决: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 ...
- 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 脚本无法连接数据库,但是可以使用 ...
- 问题解决: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 ...
- “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 ...
- 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. ...
- docker 踩坑笔记之 psql: could not connect to server
最近在用docker跑rails,也遇到了一些坑,这里记录一下. 首先build项目: docker-compose build 然后就开始报错了: psql: could not connect t ...
- 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 ...
- 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 解决方案: ...
- 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" ...
随机推荐
- VUE.js devtool 安装简易教程(转)
最简便的方法是用FQ来通过google应用商店进行安装,但是大多数人还是处在非FQ的状态 尝试过安装Node的方法来安装,但是极其不建议用这个方法安装,非常麻烦,而且必须要有node的基础,非常不接地 ...
- reactnative中FlatList上拉加载更多的解决办法
项目app中用到了list滚动加载,把List做了下对比发现FlatList比较适合自己的项目,但是在实际运用中 onEndReached方法需要给定 onEndReachedThreshold的高度 ...
- 如何自定义starter
在springboot启动流程的系列文章中,我们看过了springboot的自动配置机制,本文将基于自动配置机制自定义一个自动配置的starter示例 正文 模块结构 首先,我们准备两个模块servi ...
- 使用Canvas压缩图片
讲干货,不啰嗦,当涉及对图片有质量压缩要求的时候,可以使用Canvas实现图片压缩. 步骤: 1.获取img元素,既要压缩的图片 2.创建canvas对象 3.使用canvas的drawImage方法 ...
- bootstrap下拉框保持打开
$(".dropdown-menu li").on("click", function (e) { e.stopPropagation(); }); 停止传播事 ...
- 怎么制作电脑系统安装U盘?
现如今U盘安装电脑系统已经是非常普遍的一种方式,这种方式简单好用,能应对大多数情况,受到很多用户的欢迎. 雨后清风U盘启动是一款可将普通U盘制作为系统引导启动工具的软件,其制作的U盘启动盘融合了雨后清 ...
- c# String 常用方法应用
- IPC——管道
概述 管道通信分为无名管道.有名管道 管道通信的本质 不管是有名管道,还是无名管道,它们的本质其实都是一样的,它们都是内核所开辟的一段缓存空间.进程间通过管道通信时,本质上就是通过共享操作这段缓存来实 ...
- Subordinates(贪心)
题目大意: 一共有N个员工,其中最高领导人是编号s的人,每个人都只有一个直接领导,每个人都说出了自己领导的个数,问最少有几个人撒谎了. 思路: 合理的贪心是该把排最后的数变成缺少的数字,然后继续判断. ...
- Java字节码方法表结构深度剖析
继续上一次[https://www.cnblogs.com/webor2006/p/9459681.html]的字节码分析,这次来分析一下最为复杂的方法表的信息,如下: 而上一次分析到了属性表的位置在 ...