pg 7.18.0 in node js not working, throwing: Implicit disabling of certificate verification is deprecated and will be removed in pg 8 [duplicate] - node.js

I'm using Macbook
Psycopg2 works well when connecting the localhost db (PostgreSQL on Mac). The error was raised when I tried to connect PostgreSQL db on a Windows10.
the following code is what I have for connection, the host is just the IP of the windows10
db= psycopg2.connect(database='dbname',user='username',password="secret",host="192.168.3.9",port="5432")
Errors:
File "path/to/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0
Is this because of system compatibility or something else? I've tried other Windows machine and I got no luck to make it work.
However, I was able to connect PostgreSQL on windows while I using Node.JS module pg

1234.5679 is the special code sent by the client to request SSL-encrypted database connections, and support for that has been in PostgreSQL since commit e0e7daef6da in 1999. But your PostgreSQL cannot be that old, because support for protocol version 3.0 was not added before 2003.
Actually, from studying src/backend/postmaster/postmaster.c and reading the mailing list, this is a bug on the PostgreSQL server:
The client must be configured to try GSS authentication, and when the server rejects, it wants to negotiate an SSL connections, but the server doesn't expect that at this point; hence the error.
See the discussion here. The bug has been fixed with release 12.3.
As a workaround, disable either GSS authentication or SSL negotiation on the client.
In psycopg2, disabling SSL is done by using sslmode="disable" in the connection string, and disabling GSS is done with gssencmode="disable". See the documentation for details.

Adding ?gssencmode=disable to the connection string worked for me:
import pyodbc
from sqlalchemy import create_engine
engine = create_engine(f'postgresql://{user}:{password}#localhost:5432/database_name?gssencmode=disable')

Getting a similar error working with Laravel and Postgres. Solved it by putting this in my .env file: PGGSSENCMODE=disable

If you installed this Psycopg2 module through conda command, then uninstall that module and install using pip command.
Command:
pip install Psycopg2
The above command may resolve your issue. I resolved through this step

In order to have a SSL connection working and using certificates, you can disable GSS connection mode to avoid the client to attempt to connect with GSS and directly try a SSL connection (Postgres version 12 < 12.3, I had no such issues with a test on version 11).
Below an example with the verify-ca option, providing filenames for certificates and key (example names from GCP Cloud SQL, running Postgres 12.1 when posted).
from sqlalchemy import create_engine
db_user = 'user'
db_pwd = 'secret'
db_host = 'hostname'
db_port = '5432'
db_name = 'test'
cnn = f'postgresql://{db_user}:{db_pwd}#{db_host}:{db_port}/{db_name}'
ssl_args = {
'gssencmode': 'disable',
'sslmode': 'verify-ca',
'sslrootcert': 'server-ca.pem',
'sslcert': 'client-cert.pem',
'sslkey': 'client-key.pem',
}
engine = create_engine(cnn, connect_args=ssl_args)
This engine can then be used with pandas for example:
df.to_sql('my_table', con=engine)

Using PostgresSQL 13.0 I had the same problem, displaying the error messages:
unsupported frontend protocol 255.255: server supports 2.0
unsupported frontend protocol 0.0: server supports 2.0 to
according to this site it postgresql.org deals with the SSL / GSS Protocol Negotiation Problem. Which should already be resolved in Postgres version 12.0
I was able to solve it following the guidelines contained in these sites:
highgo.ca
In the postgres terminal, I executed the command below setting the environment variable gssencmode = disable and the problem was solved:
psql -h localhost -U postgres -d "dbname=belez gssencmode=disable";

Related

SSL error while installing datadog agent in azure databricks

I am trying to install the datadog agent on Azure databricks using the steps mentioned in https://docs.datadoghq.com/integrations/databricks/?tab=allnodes
But while executing the init script, it fails with this error : "curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to s3.amazonaws.com:443".
Tried installing the agent with python package 'datadog', still the issue persists relevant to SSL.
Please let know if there is a fix for this?
Regards.
This error message indicates that there was a system call error during an SSL connection to the Amazon S3 endpoint (s3.amazonaws.com:443). Here are a few possible solutions that might help resolve this issue:
Check your internet connection: Ensure that your machine has a stable internet connection and that it is not being blocked by a firewall or proxy.
Update OpenSSL: Make sure that you have the latest version of OpenSSL installed on your machine. Updating OpenSSL can sometimes resolve SSL-related errors.
Check your network settings: If you are behind a firewall or proxy, ensure that the firewall or proxy is not blocking access to the Amazon S3 endpoint (s3.amazonaws.com:443).
Verify the endpoint: Double-check the endpoint URL to ensure that it is correct and that you are using the correct protocol (https).
If the above steps do not resolve the issue, you may need to contact Datadog support for further assistance.

ServerSelectionTimeoutError: documentdb.documents.azure.com:10255: timed out

I am running a mongodb application to connect to azure cosmosdb running locally. I am running an already built flask app. Which port on my machine do I need to enable, to connect to the remote cosmosdb?
Anaconda environment: Python 3.6
MongoClient
replicaset is globaldb
ssl is True
My flask app gives the above error
Check this thread out: https://github.com/Azure/azure-cosmos-dotnet-v2/issues/256. Start by using /EnableMongoDbEndpoint flag and point it to 10250 port. It might work.

can not connect to postgres db from node server

I want to connect my apps nodejs using node-posgres to PostgreSQL. My apps in linux server and my postgresql in another linux server by 176.9.154.123 IP.
this is my error:
this is my pg_hba.conf:
host all all 176.9.154.123/32 trust
i can solve this problem by add this line to postgressql.conf:
listen_addresses = '*'

MongoDB: No unix socket support on windows

I use Robo 3T as a UI tool for MongoDB on a Windows 8 machine. Now I've deployed the DB to production on a Ubuntu 14 server in Amazon EC2 cloud. When I try to connect from the Windows machine to the Ubuntu one via Robo 3T, I receive the following error:
Cannot connect to the MongoDB at [http://12.345.678.90]:27017.
Error: No unix socket support on windows
Is that a problem I need to fix on my computer by installing something? or it's an issue of Mongo 3T?
If it's an issue on my Windows, what do I have to install in order to make it work?
If it's a Mongo 3T issue, do you know another UI that does support connecting from Windows to Ubuntu?
Perhaps an EC2 solution?
Or maybe some settings I need to change in Robo 3T?
I've tried changing "http" to "mongodb" to no avail. I've also tried removing the protocol prefix as suggested here but I ended up with the error:
Cannot connect to the MongoDB at 12.345.678.90:27017.
Error: Network is unreachable.
Do you have a bindIP setting in your mongo configuration file? Probably that can cause the error.
Either remove the bindIp configuration or allow your IP to access mongo server.
(restart your service after changes the configuration).

PostgreSQL version in connection string

I have two versions of postgresql installed, 9.4 and 9.5. I am using npm's pg to connect to the server using a postgres connection string. From CLI, I can connect to 9.5 by using the --cluter option like so: psql --cluster 9.5/main. In postgres' documentation for the connection string, they show one of the querystring parameters you can use is options:
options - Adds command-line options to send to the server at run-time
I realize this means configuration parameters for the server, not the client. Nonetheless, I tried constructing the connection string and including the cluster option to connect to 9.5:
postgres://user#localhost/db_name?options=--cluster%3D9.5%2Fmain
And sure enough I get: psql: FATAL: unrecognized configuration parameter "cluster"
Okay, no surprise there. However, I can't seem to connect to 9.5 no matter what I do. I even have the environment variable PGCLUSTER set to the appropriate version string, however I think this is only read from CLI (ie: not when the server is connected to via unix socket or host).
What is the easiest way to connect to the 9.5 server instead of 9.4 from a script connecting to the server via localhost?
The best approach is to find the port that the 9.5 server is running on. In my case, 9.4 was running on port 5432 whereas 9.5 was running on 5433. This is a simple change to the connection string:
postgres://user:pass#localhost:5433/db_name

Resources