首页 > 解决方案 > 我无法连接到我的 postgresql 数据库

问题描述

我在 wsl 上使用 ubuntu 20.04 并安装了 postgres true the normal sudo apt-get install。我知道有相关的问题,但没有解决我的问题。

每当我运行 psql 时,它都会返回此错误

psql: error: 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 服务器,但随后发生此错误

$ sudo service postgresql start
 * Starting PostgreSQL 13 database server                                                                                                            * Error: /usr/lib/postgresql/13/bin/pg_ctl /usr/lib/postgresql/13/bin/pg_ctl start -D /var/lib/postgresql/13/main -l /var/log/postgresql/postgresql-13-main.log -s -o  -c config_file="/etc/postgresql/13/main/postgresql.conf"  exited with status 1:
2021-06-15 22:40:51.285 CEST [74] LOG:  starting PostgreSQL 13.3 (Ubuntu 13.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-06-15 22:40:51.297 CEST [74] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2021-06-15 22:40:51.297 CEST [74] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2021-06-15 22:40:51.297 CEST [74] WARNING:  could not create listen socket for "localhost"
2021-06-15 22:40:51.297 CEST [74] FATAL:  could not create any TCP/IP sockets
2021-06-15 22:40:51.304 CEST [74] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.

标签: linuxpostgresqlpsqlubuntu-20.04

解决方案


推荐阅读