Unable to obtain Jdbc connection from DataSource, SSL error: Connection reset - postgresql

Facing connection issue while connecting to postgresql pod running in OpenShift environment. Details are as below
URL: jdbc:postgresql://XXX:5432/YYY?sslmode=require
Flyway 4.2.0 by Boxfuse
ERROR:
Unable to obtain Jdbc connection from DataSource
(jdbc:postgresql://XXX:5432/YYY?sslmode=require)
for user 'ABC': SSL error: Connection reset
Just wanted to confirm if I need to add certificates to make the connection work?
Please advise.

We have fixed this issue by upgrading flyway version to 6.0.7 and postgres driver version to 42.2.8.
The below URL string worked
jdbc:postgresql://XXX:5432/YYY?sslmode=require
Thank you all.

I would recommend checking the networking setup of your application which basically means have a look at:
The route (does a DNS record exist for your hostname? Is your route pointing to the correct service and service port?)
The service (is the target port the port your postgresql is listening on?)
The deploymentconfig (did you expose the right port?)
The postgresql (it needs to listen on 0.0.0.0 instead of localhost/127.0.0.1 -> all interfaces (a common mistake))

Related

Connecting to Fly.io Postgres from Vercel

Is it possible possible to connect to Fly.io Postgres from a NEXT.js API route served from a Vercel severless function, and if so, how?
I've read and reread the Fly.io Postgres docs, focusing especially on Connecting from outside Fly.io and (since my API routes use Prisma to connect to Postgres) Connecting with Prisma, but it seems I would need to either install flyctl or a set up a WireGuard Tunnel in Vercel, neither of which I could figure out how to do from web searches.
I found essentially the same question on the Fly.io community forum, but unfortunately, no one has answered it after 26 days (as of this writing).
To add a bit more detail, I'm familiar with Heroku Postgres, where a connection string is essentially all that's needed to connect, but it seems connecting to Fly.io Postgres requires a connection string plus a proxy created with flyctl. This was easy to get working on my local machine, but it's not clear how to do this on a remote host like Vercel.
One of the solutions is to allocate an ip address to your app with link here
fly ips allocate-v4 --app <pg-app-name>
Then add these service configurations to the fly.toml file
[[services]]
internal_port = 5432 # Postgres instance
protocol = "tcp"
[[services.ports]]
handlers = ["pg_tls"]
port = 5432
Redeploy your app with fly deploy
Go to your fly dashboard you will be able to see Ip Addresses that you can use as host to connect to the database

Cannot connect AppSmith to local PostgreSQL server

Problem
In general, there have been a ton of issues in connecting a remote service to a PostgreSQL database. The documentation for most services doesn't really have documentation for this since the task of connecting to a PostgreSQL database requires the Admin to modify both the postgresql.conf and pg_hba.conf files.
The current scenario is giving AppSmith remote access to the given server.
PostgreSQL needs to allow the following IP addresses at the pg_hba.conf: 18.223.74.85 and 3.131.104.27
Research SSL Connections and if one would be required in this case
Success Criteria:
Appsmith is able to connect to given database
Appsmith is able to read/write data to given database
Resolution Research
Allowing the above IP addresses to connect to the PostgreSQL database in the pg_hba.conf file and changing the postgresql.conf file to allow remote connections using listening_addresses = '*' did not resolve the issue. Appsmith is unable to connect to the database.
SSL Connection: SSL stands for Secure Sockets Layer and, in short, it's the standard technology for keeping an internet connection secure and safeguarding any sensitive data that is being sent between two systems, preventing criminals from reading and modifying any information transferred, including potential personal details.
SSL proved to be a dead-end for this issue with no resolution.
In order to create an SSL connection, the following steps must be followed (PostgreSQL SSL documentation: https://www.postgresql.org/docs/9.1/ssl-tcp.html):
OpenSSL needs to be installed on the host server (https://fedingo.com/how-to-install-openssl-in-ubuntu/). Determined that OpenSSL is already installed on the host server using openssl version -a.
Following the above steps from the postgresql documentation does not produce the desired result.
Following steps from https://www.cyberciti.biz/faq/postgresql-remote-access-or-connection/ does not work either.
Error in all cases on Appsmith: Failed to initialize pool: The connection attempt failed
Next-steps
Consult with the Stackoverflow community to see if anyone else is having a similar issue.
Similar issues have been found, but Appsmith documentation and the Stackoverflow community did not have the information needed to fulfill this issue. I will post the full case to the community.
I resolved this problem using ngrok to make a tcp tunnel on your localhost.
Donwload and conifg ngrok and create a new tunnel on terminal, just run ngrok tcp 5432 at terminal
After this, get the host/port and insert at Appsmith PostgreSQL Connection.
make sure your username/password is correct.
Image from host/port create on ngrok
Image to how config this host/port on Appsmith

php: fbird_connect(): Unable to complete network request to host "localhost". Failed to establish a connection [duplicate]

I'm trying to connect to a remote Firebird database "test" (alias already added). It is not an embedded server, and is installed on VM with IP 192.168.1.147.
Here is my connection string:
User=sysdba;Password=masterkey;Database=test;DataSource=192.168.1.147
However I got an error:
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Unable to complete network request to host "192.168.1.147". ---> Unable to complete network request to host "192.168.1.147".
I've done some research on that but haven't got a clue yet. Some help needed. Thanks
My IP address is 192.168.2.108, and I can ping that server IP successfully
Make sure that
Firebird is running
Firebird is listening on port 3050 on the specified IP (or on 0.0.0.0)
Your firewall allows access to port 3050
You're using the correct host name
For Linux, the Firebird port is closed by default. You need to modify RemoteBindAddress in /etc/firebird/2.5/firebird.conf from
RemoteBindAddress = localhost
to
RemoteBindAddress =
and restart service.
Make sure you have excluded tcp port 3050 in VMs' firewall.
Ok. I think your connection to firebird is faililing because the firebird client looks up the network service file by name and does not find gds_db in the services file.
If your connection string refers to the host by using IP, the Client might fail to identify it because it gethostbyname() and not by IP
Manually include this in the file and you should be fine.
C:\windows\system32\drivers\etc\services

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

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

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.