cancel
Showing results for 
Search instead for 
Did you mean: 

PostgreSQL: Could not connect to server: Connection refused (0x0000274D/10061)...

Highlighted
Adventurer

PostgreSQL: Could not connect to server: Connection refused (0x0000274D/10061)...

Hi guys, I know this might have been resolved before. I search but I didn't get anything related to this on this forum. 

 

Problem: After installing PostgreSQL 11.4-3 on my Windows Computer, I opened pgAdmin4 to connect the client to the server but I was getting this error "could not connect to server...". Check below for full error. 

 

I have tried different solutions I got online to make this work but nothing positive so far and a good friend who has been helping to fix this suggested that I should drop it here on this forum. 

 

My PC OS: Windows 10. 

Postgres version: PostgreSQL 11.4-3 (postgresql-11.4-3-windows-x64)

Client: pgAdmin4

 

Below is the error I was getting when I try to connect to the server using the client (pgAdmin 4):

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?

 

Also, this is the error from the install log file: 

Initialising the database cluster (this may take a few minutes)...
Executing cscript //NoLogo "C:\Program Files\PostgreSQL\11/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Program Files\PostgreSQL\11" "C:\Program Files\PostgreSQL\11\data" 5432 "DEFAULT" 0
Script exit code: 1

Script output:
WScript.Shell Initialized...
Scripting.FileSystemObject initialized...

Called CreateDirectory(C:\Program Files\PostgreSQL\11\data)...
Called CreateDirectory(C:\Program Files\PostgreSQL\11)...
Called ClearAcl (C:\Program Files\PostgreSQL\11\data)...
Remove inherited ACLs on (C:\Program Files\PostgreSQL\11\data)
Executing batch file 'radF2A4F.bat'...
Called Die(Failed to reset the ACL (C:\Program Files\PostgreSQL\11\data))...
Failed to reset the ACL (C:\Program Files\PostgreSQL\11\data)

Script stderr:
Program ended with an error exit code

Error running cscript //NoLogo "C:\Program Files\PostgreSQL\11/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Program Files\PostgreSQL\11" "C:\Program Files\PostgreSQL\11\data" 5432 "DEFAULT" 0: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.
[02:28:10] Delete the temporary scripts directory...
Creating menu shortcuts...
Executing cscript //NoLogo "C:\Program Files\PostgreSQL\11\installer\server\createshortcuts_clt.vbs" "PostgreSQL 11" "C:\Program Files\PostgreSQL\11"
Script exit code: 0

Script output:
Start FixupFile(C:\Program Files\PostgreSQL\11\scripts\runpsql.bat)...
Opening file for reading...
Closing file (reading)...
Replacing placeholders...
Opening file for writing...
Closing file...

End FixupFile()...
createshortcuts_clt.vbs ran to completion

 

Please, I need your help to fix this error I was getting after installing PostgreSQL 11.4 on my pc. Thank you for your time and let me know if you need more information.

 

P.S: Please, I'm connecting remotely - both server and the client is on the same machine. 

2 REPLIES 2
EDB Team Member

Re: PostgreSQL: Could not connect to server: Connection refused (0x0000274D/10061)...

Hi @drdreey,

 

From the installation logs, it looks like your post-installation step of creating the data cluster is failed.

 

Could you please check the permissions on the data directory provided, initialize the cluster, start the DB cluster and then try to connect to it.

 

Regards,

Sudhir

Adventurer

Re: PostgreSQL: Could not connect to server: Connection refused (0x0000274D/10061)...

@slonkar Thank you very much for your reply. 

 

I just want to be sure if i'm right

 

How do I:

1. check the permissions on the data directory provided

Ans: I don't know how to do this.

 

2. initialize the cluster. 

Ans: After i cd to the postgres data directory: then i can run this command right: 

C:\Program Files\PostgreSQL\11\bin\initdb -D C:\Program Files\PostgreSQL\11\data

 

3. start the DB cluster

Ans: pg_ctl -D ^"C^:^\PostgeSQL11^.5^\data^" -l logfile start

 

4. then try to connect to it.

Ans: I can connect using the pgAdmin4 or command prompt using psql command 

 

I'm new to this. 

 

Thank you for your time.