Error no pg_hba.conf entry for host when using PG client, but not when connecting with psql? - postgresql

I'm pointing my application from one PG cluster to another (changing the team that manages the PG cluster), and I'm getting connection errors when trying to connect with a language binding for javascript:
no pg_hba.conf entry for host xxx.x.x.x, user "blah", database "blah", SSL off
I'm led to believe that this is a pg_hba.conf configuration error, but I can connect to the cluster with psql, from the same machine, with the same credentials.
psql: 9.5.7,
PG cluster 10.5
Client: pg-promise 9.3.3
How can this be possible? Is this still definitely an issue with how pg_hba.conf is set up or is there something wrong with how I configured my client? This is not the first time I've used it, I've been connecting to a PG cluster v. 9.5.7 for the last couple of years.

The issue was that the new cluster is using SSL for the connection. When I connected to the old cluster, there was no SSL, so the connection worked with my current config, but when switching to the new cluster I had to specify that SSL was being used.
https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax

Related

Can't connect to PostgreSQL server from AKS

I've created an AKS cluster and Flexible PostgreSQL database.
The postgresql database is public, and I made firewall entry while setting up the DB to allow local connection from my IP - which worked fine.
When I then tried to connect from AKS, I was unable to - I was getting timeouts.
Eventually, I clicked the setting to allow access from everywhere on azure
That fixed the timeouts, and I can now connect, but I get a new error:
no pg_hba.conf entry for host "**.**.***.203"
What am I doing wrong?

Does heroku blocked connect to external databases? (postgres)

i had running my app on heroku for almost a year without any problem, my app update a postgres database on one external server and read from it, suddenly my app stopped writing and reading to/from my database apparently at the end of February, what i found in logs is that heroku is trying to connect to heroku postgres servers instead of my external database:
2022-04-16T18:32:21.042608+00:00 app[web.1]: original: error: no pg_hba.conf entry for host "52.50.8.208", user "username", database "database", SSL off
The ip 52.50.8.208 is not mine, that ip is changing every xx time, so that is why i think is from the heroku postgres service
heroku is ignoring my config var "DATABASE_URL" where i have: postgres://username:password#myserverip:port/database but heroku is trying to connect to their heroku postgres servers instead of my server ip, heroku is trying to connect with the username, password, port and database on my config var but its ignoring my server ip...
Does anyone knows if there was a change or why is ignoring my server ip on my config vars?

Error connecting server to DigitalOcean Postgresql droplet

I am aware that I can connect to a pre-configured Digital Ocean PostgreSQL database cluster and that's what I'm actually connected to right now, but I'd like to connect to a droplet instead (It's cheaper). The droplet is running Ubuntu and came set up with Node JS, PM2, and Nginx. I have already Installed postgreSQL and set up a database on it.
I try to connect to the droplet with this connection string:
DATABASE_URL="postgresql://<USERNAME>:<PASSWORD>#<DROPLET-IP-ADDRESS>:5432/<DBNAME>?schema=public"
and this is the error im getting:
Can't reach database server at `<DROPLET-IP-ADDRESS>`:`5432`\n\nPlease make sure your database server is running at `<DROPLET-IP-ADDRESS>`:`5432`.",
Whats the correct way of connecting via Prisma to a DigitalOcean droplet
If you changed listen_addresses to *, but forgotten to remove the comment (#) at the beginning of the line, the parameter will still be at its default value localhost. Check that the # is removed and restart PostgreSQL. Quite common mistake.
Also answered here by someone.

HEROKU POSTGRES error: Connection refused Is the server running on host "..compute-1.amazonaws.com..." and accepting TCP/IP connections on port 5432?

I have been trying for weeks to figure out what's the issue, but I cannot seem to fix this.
I am developing a web app, and I have deployed to production using Heroku. I'm using Heroku Postgres for my database, and I'd like to psql into that hosted database from my local machine to make changes to it. I have tried from both Mac OS X and Linux Mint.
However, no matter what I try, I keep getting the following error:
---> Connecting to HEROKU_POSTGRESQL_ORANGE_URL (DATABASE_URL)
psql: could not connect to server: Connection refused
Is the server running on host "ec2-***-**-***-**.compute-1.amazonaws.com" (***.**.***.**) and accepting
TCP/IP connections on port 5432?
I'm starting to think that I may have to SSH into the Amazon EC2 instance and change the Postgres configuration? Would that even be possible?
You can't connect directly to the EC2 instance where the Heroku Postgres instance is running; it is managed by Heroku and normal users aren't allowed to connect to it.
If your application is running fine in Heroku, and you're running heroku pg:psql to attempt to connect to the DB, then most likely there is some issue with your local network that is preventing you from connecting to the Postgres database, like a firewall blocking outbound connections. Heroku Postgres databases are open to the public without any restriction on IP ranges.
It could be a problem with the proxy or firewall of the internet connection you are using.
Try to connect your PC to your mobile phone tethering and then launch the command again, just to verify if the problem lies there.
I was getting this kind of error when my pg_hba.conf or AWS security groups have not been configured properly. There are plenty of docs about how to resolve this. For example, you can check this list link
You can directly connect to EC2 Heroku Postgress instance by adding this attributes to the end of your DB connection url:
jdbc:postgresql://<host>/<dbname>?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

general sql error

I have created an application in delphi and backend is postgres when i run the application i get the following error
general sql error.could not connect to the server;no
connection could be made because the target machine actively refused
it.[127.0.0.1:1:5433 alias resumep
I uninstalled it and installed it again but it didnt work.Even i changed the port number while installing .
I changed the password and installed again but its giving same error
what is the solution to this problem?
The database cluster of a standard PostgreSQL installation is listening on port 5432. (You can, of course, set up additional db clusters on different ports or configure your database cluster to listen on any other port.)
Any particular reason you try 5433? This is probably the cause of your problem.
If no server is listening on port 5433, the connection is simply not possible.