尽管localhost上的postgres服务器处于活动状态,但无法运行psql或访问postgresql db

时间:2019-02-12 19:28:10

标签: django postgresql

我无法为我的Django应用(目前正在运行mysql db)启动和运行postgres。我正在尝试将新用户和数据库添加到postgres服务器,但是无法这样做。我已将ssh隧道连接到网络上的服务器,该服务器上装有django应用程序和postgres服务器。

我相信postgres的安装/设置中出现了问题,因为每当运行“ psql template1”或“ createuser”时,都会出现以下错误:

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"?

但是,我认为postgres正在运行,因为当我运行“ sudo service postgresql status”时,会收到以下消息:

postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2019-02-12 09:45:52 EST; 10min ago
Process: 3585 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 3585 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service

我尝试添加

local   all    all    trust

到我的pg_hba.conf的第一个非注释行,当然恢复了服务器。 “哪个psql”返回“ / usr / bin / psql”。

我尝试过的postgresql.conf文件中的其他重要内容(不按顺序):

unix_socket_directories = '/var/run/postgresql'
listen_addresses = '*' 
logging_collector = on 
tcpip_socket = true
#log_destination = 'stderr'

由于此错误,我无法弄清楚如何进行我的postgres设置。我已经尝试了几件事,其他人对这个问题可能有什么见解吗?我也不确定在哪里可以找到日志文件,这可能有助于进一步的故障排除。我很乐意提供任何其他有用的信息。任何帮助将不胜感激,谢谢!

0 个答案:

没有答案