Hello I was trying to connect Hasura to an already existing database of postgres.
i tried all three menthods as ENV variables, URL, connection parameters.
note that I have docker of both hasura and postgress in diffrent docker compose:
Folloowing are specifications
[
{
"definition": "name",
"message": "connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused\n\tIs the server running on that host and accepting TCP/IP connections?\nconnection to server at "localhost" (::1), port 5432 failed: Cannot assign requested address\n\tIs the server running on that host and accepting TCP/IP connections?\n",
"name": "source name",
"reason": "Inconsistent object: connection error",
"type": "source"
}
]
Both docker containers are running and even with same parameters i was able yo connect pgadmin 4
Also i tried with diffrent post such as 172.17.0.4 because i was showinf this IP too for IPv4 even tried with localhost?enter image description here
I wanted to get connected with Hasura and postgres who both are running aqs independent containers in docker.
Related
Let me first mention I don't have admin privilege on my PC, So I could not install PostgreSQL with the normal process. I just download the binary files from here enterprisedb.com/download-postgresql-binaries,
and added it to environment variable paths.
My problem when I try to start a new server from pgAdmin it gives me the below error.
connection to server at "localhost" (::1), port 5432 failed: Connection refused
(0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
(0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections?
I searched a lot for a solution
The first recommendation I got is to restart postgress from windows services but I couldn't find it.
Second recommendation was to edit the psogress config file but also I can't find it at all they say that I can find it in the main directory of postgress.
I got strange behavior from dblink_connect.
I run my postgresql's servers using docker, mapped 5432 to localhost:5433.
When I am connecting to it using psql everything is fine
$ psql 'postgresql://pguser:pgpass#localhost:5433/mt5?sslmode=disable'
psql (14.4, server 10.22)
But when I connect to it from another postgresql's instance using dblink_connect it fails
psql 'postgresql://pguser:pgpass#localhost:5431/pgdb?sslmode=disable'
psql (14.4, server 14.3)
Type "help" for help.
pgdb=# select dblink_connect('postgresql://pguser:pgpass#localhost:5433/mt5?sslmode=disable');
ERROR: could not establish connection
DETAIL: connection to server at "localhost" (127.0.0.1), port 5433 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5433 failed: Address not available
Is the server running on that host and accepting TCP/IP connections?
I found the cause of error: as both instances are docker's they can't see each other as localhost: you have to use IP address of you internal network to which they exposed, like 192.168.88.22:
pgdb=# select dblink_connect('postgresql://pguser:pgpass#192.168.88.22:5433/mt5?sslmode=disable');
dblink_connect
----------------
OK
(1 row)
I figured this out while asking question!
Suppose it will help to somebody else.
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?
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?```
I have created an AWS RDS Instance with Postgres 10.6
I am trying to connect to it from my local system using below command:
psql --host=dev.xyz.ap-south-1.rds.amazonaws.com --port=5432 --user="postgres" --password --dbname=abc
The Inbound rules i have set are
Allow TCP traffic on 5432 from Anywhere.
Still I am getting below error:
psql: could not connect to server: Connection timed out
Is the server running on host "dev.xyz.ap-south-1.rds.amazonaws.com" (xxx.xxx.xxx.xxx) and accepting
TCP/IP connections on port 5432?
If Publicly accessible = No, then you will not be able to access the RDS database from outside the VPC.
This is because the DNS Name of the database will not resolve to an IP address.