connecting to PgAdmin locally from amazon EC2 postgres - postgresql

I have created an amazon ec2 ubuntu instance and installed postgres in it but unable to connect it. I have enabled security group HTTP(80), Postgres(5432) and ssh(22).
While connect in pgadmin following errors are thrown
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "54.172.***.***" and accepting TCP/IP connections on port 5432?

Related

Problem to connect to an AWS postgres instance via a bastion host via SSHTunnel in python

I have an AWS postgres instance and an AWS ec2 instance (running as bastion host). From my local machine I want to connect to that AWS postgres instance via a python script. But it's not working (see below).
My setup is:
with SSHTunnelForwarder(
('internet-adress-of-the-basion-host', 22),
ssh_private_key=r"the-private-key.pem",
ssh_username="ec2-user",
local_bind_address=('localhost', 6543),
remote_bind_address=('internet-adress-of-the-postgres-server', 5432)) as server:
server.start()
print("server connected")
self.conpostgres = psycopg2.connect(host='localhost', port=server.local_bind_port, database="the-database",
user="the-user", password="the-password")
I can sucessfully connect via the sshtunnel (the "server connected" messages is printed to the console), but I get an ERROR in the when excecuting psycopg2.connect.
The connect ERROR is:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 6543?
FATAL: password authentication failed for user "the-user"
FATAL: no pg_hba.conf entry for host "x.x.x.x", user "the-user", database "the-database", SSL off
Two remarks:
1.) In the line "no pg_hba.conf entry for host "x.x.x.x"". Here the "x.x.x.x" address is NOT localhost (127.0.0.1). It's a normal ip4 internet address. But I have no idea where this address is coming from!
2.) !!!! With the exact same configuration mentioned above I can successfully connect to the database via the database tool built in IntelliJ Idea. So there is a way to connect to the postgres server without changing pg_hba.conf. So maybe I have to configure the tunnel differently?

Postgres FDW connectivity issue from Azure RDS to AWS RDS

I was using FDW extension in PostgreSQL from 2 years to load data from one database to another database. Now, one of my RDS has been moved from AWS to Azure. Now, when I tries to make connection from Azure to AWS it says the host is invalid. So, in this case FDW doesn't works if the RDS are from different service?
Error:
Detail: could not connect to server: Network is down (0x00002742/10050)
Is the server running on host "xxxxx" (10.xx.xx.xx) and accepting
TCP/IP connections on port 5432?
could not connect to server: Network is down (0x00002742/10050)
Is the server running on host "xxxxx" (10.xx.xx.xx) and accepting
TCP/IP connections on port 5432?
could not connect to server: Network is down (0x00002742/10050)
Is the server running on host "xx" (10.xx.xx.xxx) and accepting
TCP/IP connections on port 5432?
could not connect to server: Network is down (0x00002742/10050)
Is the server running on host "xx" (10.xx.xx.xx) and accepting
TCP/IP connections on port 5432?```

Could not connect to Azure cloud hyperscale citus

i tried connecting my local postgresql to azure via hyperscale citus but got this error.
psql: error: could not connect to server: could not connect to server:
Connection timed out (0x0000274C/10060)
Is the server running on host "mydemo-c.postgres.database.azure.com" (20.42.29.217) and accepting
TCP/IP connections on port 5432?
I tried the steps asked earlier like re-configuring conf files and making available all listening ports but it didn't worked out. Any help?

Postgres remote connection

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?

What can prevent me from making remote access to postgresql?

I'm trying to make remote access to postgresql that I installed on a VM with centos 7, but I get the following error:
" Unable to connect to server:
could not connect to server: Connection refused Is the server running
on host "xxx.xxx.xxx.xxx" and accepting TCP/IP connections on port
5432? "
know that I have already changed the files pg_hba.conf and postgresql.conf but this did not work