I have a problem to connect server for Postgres after I updated my windows.Before I update there is no problem to open the database. My database in Postgres also gone. When I want to create my new database it show this 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?
On windows, Just go to the 'Services'. Start/Restart the postgresql-X64 service. It worked for me as my service was in stopped state somehow.
There are two items to configure if your server isn't on localhost:
find your postgresql.conf and add your server's public IP address to the end of the setting listen_addresses (separate multiple entries by commas); uncomment the line if it is commented out (e.g. with '#')
add a line to pg_hba.conf containing your client's IP address - you may copy the line containing 127.0.0.1 and change only the IP address
On Ubuntu, these files are in /etc/postgresql/<version>/main/
.
In my case I couldnt' open the pgAdmin4, for some reason. I use Postgresql 10 and pgAdmin4
The port
in the postgresql.conf
was not the same as in the pgAdmin4 --> postgreSQL 10 --> properties --> Connection --> port.
I fixed it and it worked. Check if those 2 are in line.
First press win key+R Search for services.msc A window will open in that find postgresql-x64-13 and open that, in that tab click start option For me its works perfectly.
Faced this problem immediately after installing on Windows. At startup the pgAdmin gave this error which means that the server is not running. For me the solution was: Start -> Control panel -> Administration -> Services -> postgresql-x64-12 - start or restart
Go to PgAdmin Right click on PostgreSQL 3.Choose properties At the top, select connection Try changing the port from 5433 to 5432 or vice versa.
And re-enter.
5433
, and I deleted v13 completely which was running on port 5432
... and I am not able to use psql
command... don't know why :(.. what should I do any idea ? And on changing port from pgAdmin I am not able to connect.. giving that same error..
On windows, Just go to the 'Services'. Start/Restart the postgresql-X64 service. It worked for me as my service was in stopped state somehow.
worked for me
This happened because I installed two versions of Postgres (v12 and v13). Psql 12 was installed later so got the port 5433. I needed to use Postgres 12. To fix this particular case:
Go to Program Files/Postgres/
Open Windows Services (Press Cmd + R then type services.msc)
Stop the service for the version you don't want (You can stop it permanentally from the Right Click > Properties menu.)
Start the service for the version you want.
I think the problem is with your server listening to default public IP address. For example in the PostgreSQL package, your sever is set to listen to localhost as default public address which when you launch/ run database, the address might be something like '127.0.0.1'
To fix you can try change localhost to '' as in "listen_addresses = ''".
As seen as "listen_addresses = 'localhost'"
under "Connection Settings
" in the postgresql.conf file
.
Also to access your postgresql.conf
file, go to:
On Windows, the file is in /Program Files/PostgreSQL/<version>/share/.
On Ubuntu, these files are in /etc/postgresql/<version>/main/.
P.S: Changing the defaults 'localhost'; to '*' will let your server listen to any public database address either "localhost, 127.0.0.1 etc.
I know you might have fix this, just for others that might run into the same issue in the future. Hope it was helpful
goto service and start postgresql-x64-10 service
steps
run -> services.msc -> find postgresql-x64-10 -> start the service
services image
This is a note for a normal user. If using an official installer, it should have a built-in service,
Win+R and type services.msc Search Postgres service based on the version installed, e.g., "postgresql-x64-13 - PostgreSQL Server 13" Click stop, start, or restart the service option If you don't see start/stop or if these buttons are disabled, then double-click on the PostgreSQL and change startup type to automatic and click on start. This will start the PostgreSQL every time automatically whenever you start your system.
I had the same issue, so, I uninstalled postgres. And during reinstallation I noticed the error:
"Failed to load SQL modules into the database cluster"
And:
"Problem running post installation step.Installition may not complete correctly. Error reading file C:/Program Files/PostgreSQL/14/data/postgresql.conf"
.
I cancelled the installation and then tried again, but with a plain-text password this time, and it worked. It turned out that the special characters in my password were the problem.
I got this error message when I moved my database to another computer.
I also got some error messages when starting the server first with
pg_ctl -D /wherever/your/database/is start
which were
pg_ctl: another server might be running; trying to start server anyway server starting DETAIL: File "/wherever/your/database/is/PG_VERSION" does not contain valid data. HINT: You might need to initdb.
In my case rather than running initdb this command actually fixed the issue
pg_ctl -D /wherever/your/database/is restart
You might have changed the permissions of the 'PostgreSQL 12' in 'services.msc'. Or maybe it is not started and you are trying to start the server when Postgre 12 is not running.
Try these:
Try to start the 'PostgreSQL 12' in 'services.msc' manually. Try restarting your PC If nothing helps, try reinstalling PostgreSQL (pgAdmin 4) from the scratch.
Go to C:\Program Files\PostgreSQL\13\data
, edit postgresql.conf
with notepad.
Change:
#port = 54XX
To:
port = 54XX
(change requires restart)
restart service at "service system" on window.
Solutions:
Open Services and make sure that postgresql-x64-14 is running. Go to C:\Program Files\PostgreSQL\14\data and open postgresql.conf with notepad, find and change port to e.g 5432 and after that open Services and restart postgresql-x64-14.
Using psql with single quotes fails:
psql -c 'Select version();' 'postgresql://username:password@db.abcdefghi.ap-southeast-2.rds.amazonaws.com:8080/the_db'
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?
Using double quotes works:
psql -c "Select version();" "postgresql://username:password@db.abcdefghi.ap-southeast-2.rds.amazonaws.com:8080/the_db"
PostgreSQL 10.14 on x86_64-pc-linux-gnu, compiled by x86_64-unknown-linux-gnu-gcc (GCC) 4.9.4, 64-bit (1 row)
After a wasting 3-4 hrs i find the solution something like this
First set path in enviroment variable.And then make port and psql connecting same i.e 5432 or 5433
If you newly installed the pgAdmin
, and you did not remember to install PostgreSQL
at that time, you get that error. Make sure you install both pgAdmin
And PostgreSQL
.
For me I was getting this error and unable to open the server in PgAdmin is because I very often forgot to start the server, one for the way you can start the server with is by running this commands on cmd, make sure you provide the right path
cd "C:\Program Files\PostgreSQL\14\bin"
pg_ctl -D "C:\Program Files\PostgreSQL\14\data" start
When I run psql
, it gave me the same error, and it was because I changed the port while setting Postgres in the installation process.
I had to change back to the default port 5432 in PostgreSQL.conf (which can be found in the data directory) i.e
C:\Program Files\PostgreSQL\14\data>
The problem is no more!
And so for the new arrivals. If you are using pgAdmin and a Windows operating system, do some research to resolve the issue.
Make sure you have Postgresql installed or active
To do this, go to windows services (press Cmd + R and run the services.msc command)
Look in the list for a service called postgresql-x{BIT}-{Version}-PostgreSQL Server {Version}
Solution 1: If you don't find the service, then PostgreSQL is not installed or has been uninstalled, install it again.
Solution 2: If you find the service, but you still can't log in, then most likely the service is not active for some reason, select the service and click the Start or Restart button