psql: error: could not connect to server: 拒绝连接解决

冷不防 2024-03-31 17:57 158阅读 0赞

在部署启动postgresql数据库时遇到这样的问题
通过以下方式得以解决

  1. [pg13@machine ~]$ psql -d postgres
  2. psql: error: could not connect to server: 拒绝连接
  3. Is the server running locally and accepting
  4. connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

1.检查并关闭防火墙状态

  1. [root@machine postgresql-13.5]# systemctl stop firewalld.service
  2. [root@machine postgresql-13.5]# systemctl disable firewalld.service

2.检查服务是否启动,我这边是发现并没有启动

  1. [pg13@machine ~]$ pg_ctl status
  2. pg_ctl: no server running

启动

  1. [pg13@machine ~]$ pg_ctl start
  2. ***中间省略***
  3. done
  4. server started

3.加载环境变量

  1. [pg13@machine ~]$ source /home/pg13/.bash_profile
  2. [pg13@machine ~]$ source /home/pg13/.bashrc

4.重新连接,成功

  1. [pg13@machine ~]$ psql -d postgres
  2. psql (13.5)
  3. Type "help" for help.

发表评论

表情:
评论列表 (有 0 条评论,158人围观)

还没有评论,来说两句吧...

相关阅读