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" ...
随机推荐
- 定义Java类实现字节流转字符流
package com.buaa.comparable; import java.io.BufferedReader;import java.io.File;import java.io.FileIn ...
- 判断对象是否为null
Person p=teacher as person; If (p!=null ) dostring (); 使用这样的方法效率高 使用 is时 进行两次判断效率低
- Image Processing and Analysis_21_Scale Space:Scale-Space for Discrete Signals——1990
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- process exporter 配置项解释
process exporter在prometheus中用于监控进程,通过process exporter,可从宏观角度监控应用的运行状态(譬如监控redis.mysql的进程资源等) 配置文件样例如 ...
- 【问题】Difference between ">/dev/null 2>&1" and "2>&1 >/dev/null"
https://www.unix.com/shell-programming-and-scripting/125947-difference-between-dev-null-2-1-2-1-dev- ...
- 计算广告(5)----query意图识别
目录: 一.简介: 1.用户意图识别概念 2.用户意图识别难点 3.用户意图识别分类 4.意图识别方法: (1)基于规则 (2)基于穷举 (3)基于分类模型 二.意图识别具体做法: 1.数据集 2.数 ...
- linux配置全局环境变量-jdk
1.vi /etc/profile 2.输入大写G,定位内容末尾. 3.在末尾输入 export JAVA_HOME=/home/order/soft/jdk PATH=$PATH:$HOME/.lo ...
- laravel本地开发环境的安装及配置 - Windows:安装 Laravel Homestead 虚拟机
一.安装 VirtualBox-5.2.22-126460-Win.exe 和 vagrant_2.2.2_x86_64.msi(可视化安装包安装); 安装在D盘 二.导入 Homestead Vag ...
- c++类的基本形式(一个简单类的简单sample,命名空间)
有人把类说成是占用固定大小内存块的别名,其定义时不占用空间 #include<iostream> #include<string> using namespace std; c ...
- java内存溢出定位
一.内存溢出问题分类 瞬时流量过大造成的创建大量对象 内存泄漏导致的内存溢出,一般就是程序编码的BUG引起的 二.内存泄漏问题分析 step1: 收集内存泄漏的堆内存异常日志 > 添加HeapD ...