When I run python3 manage.py makemigrations.
It throws the following error.
File "/usr/local/lib/python3.5/dist-packages/psycopg2/init.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
So I had checked whether postgres is working fine
I had tried sudo su - postgres
It went inside the postgres cmd prompt so it became
postgres#ip-10-254-3-58:~$
now when I try psql I get the same error as when I run python3 manage.py makemigrations.
postgres#ip-10-254-3-58:~$psql
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"?
Please help me in fixing this issue.
TIA
Kind Regards,
Bharath AK
Related
I know there are a lot of similar questions on this site, but so far I've been unable to find any answers. I have a postgres 13 server running on a WSL distro, ubuntu 20.04. I am trying to connect a gui to the server. I've tried Postbird and pgAdmin 4, both give me a similar error:
'Unable to connect to server:
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?'
Steps I have tried:
I can connect to the server inside of ubuntu by running psql.
I have changed the postgresql.conf file to include listen_addresses = '*'
I have modified the pg_hba.conf file to look like:
pg_hba.conf
I have confirmed that the server is indeed running on port 5432.
Thanks for reading. Any advice would be greatly appreciated.
Ok! So my issue was indeed the pg_hba.conf file. I had to add a line at the bottom
host all all 0.0.0.0/0 trust
Once I did that, I restarted my server and was able to connect.
I install pgadmin4 using the following command sudo install pgadmin4 and then I installed postgresql using sudo install postgresql . In my terminal I ran the command psql -U postgres -h localhost
It shows connection refuse
Then I go to pgadmin4 and created a server and I wanted to connect to the server it shows
pgadmin connection refuse
Then I wrote host all all all md5 in pg_hba.conf file and I wrote listen_addresses = '*' to postgresql.conf file. and I wrote the following command sudo service postgresql restart but again It shows connection refuse message.
I wrote psql and it shows connections on Unix domain socket
Can you please help me in this regard? What I have missed?
Hello I have installed PostgresSQL 11 on CentOS Linux release 7.6.1810.
I have edited files pg_hba.conf
host all all all md5
And postgresql.conf
listen_addresses = '*'
However, following a restart I am unable to connect from pgAdmin with error:
could not connect to server: Connection refused (0x0000274D/10061) Is
the server running on host "10.190.9.130" and accepting TCP/IP
connections on port 5432?
If I run Docker container on the same server with postgres it connects successfully. Has anyone had this issue with a manual postgres install?
I missed a bit with chmod and permissions.
And now got a lot of problems with access to folders.
If I start server I see in browser:
could not connect to server: Connection refused Is the server running
on host "localhost" (::1) and accepting TCP/IP connections on port
5432?
could not connect to server: Connection refused Is the server
running on host "localhost" (127.0.0.1) and accepting TCP/IP
connections on port 5432?
command
service --status-all
tells that postgres works
[ + ] postgresq works
Next I changed next files
sudo nano /etc/postgresql/9.5/main/postgresql.conf
#listen_addresses = 'localhost'
to
listen_addresses = 'localhost, server_ip, *'
sudo nano /etc/postgresql/9.5/main/pg_hba.conf
add
host all all server_ip/24 trust
then command
psql -U postgres -h server_ip
and error
psql: could not connect to server: Connection refused
Is the server running on host "95.213.200.26" and accepting
TCP/IP connections on port 5432?
The following chain of actions leads to a slightly different error
command
which psql
answer
/usr/bin/psql
sudo su - postgres
No directory, logging in with HOME=/
psql
psql: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Wich file permissions do I have to change here?
Check that unix_socket_directories on the server is set to the same directory (/var/run/postgresql) as the default socket directory that was configured when the client was compiled (this requires a server restart).
Alternatively, you can use the --host option of psql or set the PGHOST environment variable to tell the client to look for the socket file in /tmp, where the server creates it.
It looks like client and server are from different installations, otherwise the configured default should be the same for both. Or you have a bad PGHOST environment variable set by accident.
Check listen addres syntax. Use:
listen_addresses = '*'
For the server to listen on both localhost and the server ip.
This question is really hard. I made a great mistake with permissions 777 for / folder and whole system broke. So it is really easier delete server and start new project.
I have installed PostgreSQL. However everytime I try to connect through PGAdmin or through psql it gives me the below error.
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?
I checked the postgresql.conf file and the line: listen_addresses = '*' isn't commented out.
Also this is how my pg_hba.conf file is set:
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Can anyone please advise on how I can resolve this issue?
Thanks!
Use services "start -> run -> services.msc" and look for the postgresql-[vers] service.
If it is not running try to start it, if it won't start open the event-viewer (start -> run -> eventvwr) and look for error messages relating to the PostgreSQL service.
In my case it was postgres.config. The port was somehow changed to 5433 in there and I do not remember doing it myself lol. So make sure your ports are matching up in your project vs postgres.config
pg_hba.conf.txt has to be called pg_hba.conf.
Beyond this, when you have en authentication error you will get a message similar to:
psql -U nonexistent
psql: FATAL: Peer authentication failed for user "nonexistent"
The error you are getting means most likely that PostgreSQL is not started on this server.
You can start PostgreSQL with:
service postgresql start
service postgresql status
This worked for me -
In C:\Program Files\PostgreSQL\data\postgresql.conf set listen_addresses ='localhost'
Then try -
pg_ctl -D "C:\Program Files\PostgreSQL\9.5\data" start
if already try restarting using pg_ctl
It works for me.
Remember, whatever comes after -D should be the path to where you installed PostgreSQL, to the data folder, which holds the pg_hba.conf and postgresql.conf files.
pg_ctl start -D "C:/Program Files/PostgreSQL/9.6/data"
Maybe you can try this.
Open cmd and insert.
"C:\Program Files\PostgreSQL\11\bin\pg_ctl.exe" runservice -N "postgresql-x64-11" -D "C:\Program Files\PostgreSQL\11\data" -w
Hit enter...