I have a Django project, I want to switch from SQLite
to PostgreSQL
.
After installation, I can't run the command psql
Here is the traceback:
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?
OS: Windows
TCP/IP connections are not enabled by default, so you probably have to edit a file called postgres.conf:
vi /etc/postgresql/9.4/main/postgresql.conf
For you it may reside in a different location. Look for a line saying:
#listen_addresses = '' # what IP address(es) to listen on;
Change it to this:
listen_addresses = '*' # what IP address(es) to listen on;
Right under this there's the port setting. For me it reads:
port = 5432 # (change requires restart)
Higher up in the same file there is a reference to another config file:
hba_file = '/etc/postgresql/9.4/main/pg_hba.conf' # host-based authentication file
Go ahead and edit that file. You should insert a line like this:
host all all 192.168.1.0 255.255.255.0 trust
Your IP may be different. (Once you ensure this is working, you can change "trust" to "md5" for better security.) After doing this, you need to restart the postgres server.
/usr/lib/postgresql/9.4/bin/pg_ctl restart
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.