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?
asked Nov 10, 2016 at 16:23
6
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.
answered Feb 23, 2020 at 7:06
gagan chhabragagan chhabra
1,3151 gold badge8 silver badges9 bronze badges
4
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 settinglisten_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/
.
answered Mar 14, 2017 at 1:12
1
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.
answered Sep 12, 2020 at 13:55
2
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.
answered May 31, 2021 at 5:03
VADHANVADHAN
2213 silver badges2 bronze badges
1
- 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.
answered May 15, 2021 at 17:27
1
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
answered Aug 7, 2020 at 21:49
Tim UzlovTim Uzlov
1712 silver badges6 bronze badges
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
answered Sep 10, 2020 at 18:00
devyan91devyan91
791 silver badge6 bronze badges
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/<required_version>/data
Open the
postgresql.conf
fileSearch for
Port
and change the port number to 5432. -
Open Windows Services (Press
Cmd + R
then typeservices.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.
answered Aug 7, 2021 at 14:30
Nitin NainNitin Nain
4,8921 gold badge38 silver badges51 bronze badges
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
answered Jul 31, 2019 at 14:41
Solutions:
-
Open
Services
and make sure thatpostgresql-x64-14
is running. -
Go to
C:Program FilesPostgreSQL14data
and openpostgresql.conf
with notepad, find and changeport
to e.g5432
and after that openServices
and restartpostgresql-x64-14
.
answered Apr 11, 2022 at 16:06
MaceMace
966 bronze badges
1
goto service and start postgresql-x64-10 service
steps
- run -> services.msc -> find postgresql-x64-10 -> start the service
- services image
answered Mar 12, 2021 at 14:33
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.
answered Jul 6, 2021 at 2:54
Manoj SwamiManoj Swami
672 silver badges12 bronze badges
1
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.
ouflak
2,43810 gold badges43 silver badges49 bronze badges
answered Oct 1, 2021 at 14:48
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 FilesPostgreSQL14data>
The problem is no more!
answered Jul 19, 2022 at 15:19
1
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 startingDETAIL: 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
answered May 10, 2018 at 13:42
uosjeaduosjead
4166 silver badges5 bronze badges
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.
answered Mar 30, 2021 at 12:18
Go to C:Program FilesPostgreSQL13data
, edit postgresql.conf
with notepad.
Change:
#port = 54XX
To:
port = 54XX
(change requires restart)
restart service at «service system» on window.
Tony Joseph
1,7822 gold badges16 silver badges17 bronze badges
answered Apr 20, 2021 at 17:54
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)
answered Jul 14, 2021 at 1:40
Jeremy ThompsonJeremy Thompson
59.7k32 gold badges184 silver badges308 bronze badges
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
answered Sep 18, 2021 at 3:21
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
.
answered Jan 6, 2022 at 11:14
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 FilesPostgreSQL14bin"
pg_ctl -D "C:Program FilesPostgreSQL14data" start
answered Apr 13, 2022 at 6:42
DINA TAKLITDINA TAKLIT
5,8829 gold badges61 silver badges72 bronze badges
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 theservices.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
answered Mar 24, 2022 at 4:41
Harvey DentHarvey Dent
1,9113 gold badges8 silver badges15 bronze badges
Other computers are having trouble even finding the running Postgresql 9.1 on my Windows 7 machine. Local connections work just fine of course.
In my pg_hba.conf I have:
#office subnets
host all all 192.168.##.0/24 md5
host all all 192.168.##.0/24 md5
In postgresql.conf I have (Yes, port 5433 is intentional):
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
port = 5433 # (change requires restart)
Upon running netstat -a -b
in the cmd I find:
Can not obtain ownership information
TCP 0.0.0.0:5433 XXXXX-PC:0 LISTENING
Heck, I even made a firewall exception:
Protocols and Ports:
Local port: Specific Ports, 5433
Remote port: All Ports
Scope: Any IP Address
Advanced: Profiles: Private, Public
Programs and Services: Apply to this service: postgresql-x64-9.1
The typical response from pgAdmin is always the dreaded:
Server doesn't listen
could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "...." and accepting TCP/IP connections on port 5433?
Any ideas?
The PostgreSQL error “Could not connect to server” can happen for various reasons. Often it is enough to restart the open source database management system or adjust the TCP/IP settings.
Contents
- Requirements
- “Could not connect to server: No such file or directory”
- “Could not connect to server: Connection refused”
Requirements
- Cloud Server running Linux (CentOS 7 or Ubuntu 16.04)
- PostgreSQL installed and running.
vServer (VPS) from IONOS
Low-cost, powerful VPS hosting for running your custom applications, with a personal assistant and 24/7 support.
100 % SSD storage
Ready in 55 sec.
SSL certificate
“Could not connect to server: No such file or directory”
The PostgreSQL error “Could not connect to server: No such file or directory” usually means that PostgreSQL is not running. However, the error is actually often related to issues withpermission.
First, use the systemctl status postgresql command to check PostgreSQL’s status:
user@localhost:~# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: **active** (exited) since Thu 2017-03-23 21:34:03 UTC; 14s ago
Main PID: 24289 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/postgresql.service
Mar 23 21:34:03 localhost.localdomain systemd[1]: Starting PostgreSQL RDBMS...
Mar 23 21:34:03 localhost.localdomain systemd[1]: Started PostgreSQL RDBMS.
Mar 23 21:34:08 localhost.localdomain systemd[1]: Started PostgreSQL RDBMS.
If the status is shown as active, restart PostgreSQL with the systemctl restart postgresql command. If the status is shown as inactive, start PostgreSQL with the systemctl start posgresql command.
If a restart does not fix the problem, look at the permissions of your directory with the path /var/lib/postgresql/9.6/main. The version number 9.6 may differ depending on your installation. It is expected that permissions for folders are set to “0700” and permissions for files are set to “0600”. This means that folders must have read, write, and execute permissions, and files must have read and write permissions. Use the ls command in the path above to display current permissions.
If you find permissions are different, run the following commands in the command line:
sudo chown -R postgres:postgres /var/lib/postgresql/9.6/
sudo chmod -R u=rwX,go= /var/lib/postgresql/9.6/
Restart PostgreSQL as shown above.
“Could not connect to server: Connection refused”
Another variant of the PostgreSQL error is “Could not connect to server: Connection refused”.
First, use the systemctl-status postgresql command to verify that PostgreSQL is running. To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql.
If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.
To correct this, edit your posgresql.conf file. These can be found in one of the following file paths, depending on your Linux distribution:
- Ubuntu 16.04: sudo nano /etc/postgresql/9.5/main/posgresql.conf
- CentOS 7: sudo nano /usr/pgsql-10/share/postgresql.conf
Check the listen_address configuration. To allow TCP/IP connections, it should be set to “0.0.0.0” (to allow connections from all IP addresses) or to the specific IP address of the server it will allow to connect.
If this configuration is left blank or set to localhost, PostgreSQL will not allow external TCP/IP connections. This also corresponds to the default setting of PostgreSQL.
PostgreSQL will not be able to connect to the server when the connection is blocked by a firewall. Note that all Cloud Servers are affected by the default Firewall Policy which is controlled from the Cloud Panel.
Cloud backup from IONOS
Make costly downtime a thing of the past and back up your business the easy way!
PostgreSQL: a closer look at the object-relational database management system
The PostgreSQL database management system, also known to many as Postgres, has many decades of development behind it. It originally started as a project at Berkeley University in California. Today, the open source database continues to defy solutions from commercial competitors, since the development team is constantly working on its functionality and performance. But what exactly is PostgreSQL?…
PostgreSQL: a closer look at the object-relational database management system
Change the PHP Version on a Plesk Server
Learn how to change the PHP version for a server with Plesk. This tutorial includes instructions on how to find the PHP version your Plesk server is using, change to a different PHP version, and install a different PHP version if necessary.
Change the PHP Version on a Plesk Server
Fixing SSH Errors
Learn how to resolve some of the most common errors you may receive when connecting to a server with SSH. You can find the most common errors in this guide.
Fixing SSH Errors
Install PostgreSQL on Windows Server 2016
PostgreSQL is an open source object-relational database system with over 15 years of active development and a reputation for reliability. Learn how to install PostgreSQL on Windows Server 2016.
Install PostgreSQL on Windows Server 2016
PostgreSQL backup with pg_dump and pg_restore
Creating database backups is one of the standard tasks of web and system admins. Each database management system comes with its own tools for creating backups. PostgreSQL has the command line programs pg_dump and pg_restore. The command line interface psql is also used. We’ll present you with the most common backup scenarios with examples of the required code.
PostgreSQL backup with pg_dump and pg_restore
Hi Guys, Welcome to Proto Coders Point. This article is on the solution i.e “pgadmin unable to connect to server”, “could not connect to server: Connection refused”.
Here are 2 issue you may face while connecting to postgresql server using pgadmin.
1. Could not connect to server: Connection refused
2. Unable to connect to postgres server at IP port 5432 failed: timeout expired
Solution 1 – Check if postgresql server is active
run below cmd to check postgresql status
sudo service postgresql status
If it InActive, restart postgresql
sudo service postgresql restart
Solution 2: enable postgres to allow remote connections
By default postgresql remote connection is disabled for globally accessing db using server IP & can only by accessed locally on server itself.
ss -nlt | grep 5432
This should give response as running on global 5432, i.e. 0.0.0.0:5432. This means that psql is now enabled for remote access.
Check out this article to enable postgres to allow remote connections.
Solution 3: All PostgreSQL port 5432 Inbound rules on cloud instance
Check if you have Added Inbound rules for allowing incoming traffic to port 5432, Add Inbound rules, as shown in below image.
After postgres configuring as soon in above steps, you will sure be able to connection postgresql server using pgadmin.
@Stepan47
Я программист, преимущественно на Python, Java, С#
Я при создании сервера на pgadmin, сталкиваюсь с ошибкой:
Unable to connect to server:
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?
Вот скриншот если кому не понятно где и как я это делаю:.
Вопрос короткий довольно короткий, как создть сервер?
-
Вопрос заданболее двух лет назад
-
2819 просмотров
Сначала нужно создать базу данных postgress (или другую), сделать на ней пользователя, и подкючить ее к pgadmin.
Пригласить эксперта
pgadmin — упрощенно «программа» для управления [уже работающим] сервером
то есть как минимум надо средствами ос установить и запустить postgresql хотя бы с минимальными настройками (логин, пароль)
Похожая проблема:
Сервер PG запущен на хосте. На этом же хосте запущен контейнер docker с pgAdmin.
В интерактиве на PG создан клиент postgres/пассворд и база postgres (как просят книжки)
В конфиге сервера листенер переписан в «*».
На докере создана дополнительная виртуальная сеть и контейнер pgadmin привязан к ней.
IP хоста из контейнера пингуется…
pgAdmin с базой не соединяется
какие еще есть варианты?
-
Показать ещё
Загружается…
05 февр. 2023, в 00:09
5000 руб./за проект
04 февр. 2023, в 20:45
1000 руб./за проект
04 февр. 2023, в 20:04
35000 руб./за проект
Минуточку внимания
Hi,
Can you provide your docker version, docker-compose version and operating system?
Can you ping localhost:5432 to check if something it is running something?
Otherwise it is probably because, for security reasons, a PostgreSQL server “out of the box” doesn’t listen on TCP/IP ports.Instead, it has to be enabled to listen for TCP/IP requests.
This can be done by adding tcpip = true to the postgresql.conf file for Versions 7.3.x and 7.4.x, or listen_addresses=’*’ for Version 8.0.x and above; this will make the server accept connections on any IP interface.
ref: https://www.pgadmin.org/docs/pgadmin4/dev/connect_error.html
I have the same issue, offcourse changing postgres conf in a docker container is a pain in the ass, someone managed to do it ?
Thanks all
Some hack that worked for me :
docker inspect container_name_or_hah
Then find your local ip address that is bind to the postgres container and you use it in the pgAdmin configuration
Ok, I had the above trouble, and saw this screen:
So, I ran docker inspect postgres_container
I got a long stream of JSON as a result, but half way down was config
block. The first entry in this was `»Hostname»: «4765bite0me3112»
I entered 4765bite0me3112
as the Host name/address
in the dialog, and it connected immediately.
jneterer and kenchoong reacted with laugh emoji
jneterer and kenchoong reacted with hooray emoji
jneterer and kenchoong reacted with heart emoji
jneterer and kenchoong reacted with rocket emoji
You can also use postgres
as host name since it is the service name in the compose file.
Other services(for instance pgadmin4) in the same network will resolve it.
afonsolage reacted with laugh emoji
uncleGena, afonsolage, and faouziMohamed reacted with heart emoji
afonsolage and faouziMohamed reacted with rocket emoji
mac
hostname: host.docker.internal
FranciscoMendes10866, andrej-p, ysnghr, VladislavRUS, GonzaSanchez, tenessy0570, and tqwewe reacted with heart emoji
mac
hostname: host.docker.internal
Windows works too, thank you
if you closed the pgadmin from the task manager it will be a problem after rerun it again so if you did that you just need to do the next steps:
1-go to search windows write «services» click enter
it will open a services window than
2-search for «postgresql»
3-right click and again click in proprieties
4- and last one click start
run again your pgadmin and it will work
good luck
So, I ran
docker inspect postgres_container
I got a long stream of JSON as a result, but half way down wasconfig
block. The first entry in this was"Hostname": "4765bite0me3112" I entered
4765bite0me3112as the
Host name/address` in the dialog, and it connected immediately.
Yes, hashed hostname worked for me too. This is very confusing though.
I also use adminer in the same way (as a docker container to access the postgres docker container) and it is able to figure this out without any user input. Worth adopting that approach as a default
You can also use
postgres
as host name since it is the service name in the compose file.
Other services(for instance pgadmin4) in the same network will resolve it.
Didn’t work for me:
**Unable to connect to server:
could not translate host name «93ed5fee89db» to address: nodename nor servname provided, or not known**
Ok, I had the above trouble, and saw this screen:
So, I ran
docker inspect postgres_container
I got a long stream of JSON as a result, but half way down was
config
block. The first entry in this was `»Hostname»: «4765bite0me3112»I entered
4765bite0me3112
as theHost name/address
in the dialog, and it connected immediately.
Need to put docker container name in place of localhost:
I up this compose and all is good except when I add a new server in pgAdmin to connect to postgres, it says: Unable to connect to server:
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? could not connect to server: Address not available Is the server running on host «localhost» (::1) and accepting TCP/IP connections on port 5432?
my new server: Host: localhost port: 5432
I can connect through local pgAdmin installation though, but not the one on localhost:5050.
Is it only me having this problem? Am I missing something?
You need to put in place of localhost, your docker container name: