2016-09-17 1008 views
0

有人可以帮助我,因为我有在Django的一个项目,我在最后阶段,我不想使用SQLite了,所以我安装PostgreSQL的。PostgreSQL的:无法连接到服务器:连接被拒绝

安装后,它是不可能的,我连接从命令提示符给psql。 (在Windows 10)

这里是显示错误:

psql: could not connect to server: Connection refused (0x0000274D/10061) 
    Is the server running on host "localhost" (::1) and accepting 
    TCP/IP connections on port 5432? 
could not connect to server: Connection refused (0x0000274D/10061) 
    Is the server running on host "localhost" (127.0.0.1) and accepting 
    TCP/IP connections on port 5432? 
+0

确保你有postgres守护进程运行 – karthikr

+0

你是什么意思?因为我是新的postgreSql,我必须确保守护进程正在运行? – Lemayzeur

+0

你是如何安装postgresql的?如果您使用EnterpriseDB安装程序,则应该有一个名为postgresql的服务,该服务应该正在运行。 – Eelke

回答

1

TCP/IP连接,默认情况下未启用,所以你可能需要编辑一个文件名为postgres.conf:

vi /etc/postgresql/9.4/main/postgresql.conf 

对你而言,它可能位于不同的位置。寻找一条线的说法:

#listen_addresses = ''  # what IP address(es) to listen on; 

它改成这样:

listen_addresses = '*'  # what IP address(es) to listen on; 

右下这有端口设置。对我来说,有这么一句话:

port = 5432    # (change requires restart) 

越往上在同一个文件中,有另一个配置文件的引用:

hba_file = '/etc/postgresql/9.4/main/pg_hba.conf' # host-based authentication file 

来吧,编辑该文件。你应该插入这样一行:

host all all 192.168.1.0 255.255.255.0 trust 

你的IP可能不同。 (一旦你确保这个工作正常,你可以改变“信任”为“md5”以获得更好的安全性。)完成后,你需要重新启动postgres服务器。

/usr/lib/postgresql/9.4/bin/pg_ctl restart 
+0

罗尼,我是在Windows,而不是Linux ..我做得很好我的虚拟Ubuntu Linux系统。但我不能在窗户上,我想在窗户上做到这一点。该项目是win10 – Lemayzeur

+0

嗨,你可以连接到服务器本地?从同一台Win10机器运行psql。如果可以,那么你可以尝试在防火墙创建入站规则,以允许访问端口5432 –

+0

此外,它会很高兴知道你输入什么命令。 –

相关问题