I am getting errors on connecting to remote heroku postgresql database - database

I was working on my project that was using remote heroku postgresql database, that was working fine. Actually, I was using the sqlalchemy library to connect to remote database and I was also used to queries that remote database through my Ubuntu terminal by using psql name_of_remote_database_url command. But after sometime it is giving me a bundle of errors.
And my project was on flask web application now, I am getting errors from this also.
enter image description here
I tried so much but I failed so, that's why I am posting my question here! If anyone knows then plz explain!
pg_hba.config something looks like this

Please read following Heroku support information:
FATAL: no pg_hba.conf entry for host "…”, user “u…”, database “d…”,
SSL off
You are attempting to establish a database connection without SSL. SSL
is required for all connections. Please see the documentation for your
postgres driver on how to establish encrypted connections.
Recommended solution:
Heroku Postgres & SSL

Actually, I was using remote heroku database url. After sometime, heroku did maintenance of my database and changed the url and I was considering the problem related to my system, but it was not related to that.
When I visited my gmail there was written in the heroku gmail that we changed the url of your remote database during maintenance.
Now, it's working fine!

Related

Update A PostgreSQL Database to Heroku without AWS

I have a local PostgreSQL Database for my Discord Bot on my PC and want to update to my Heroku Application. I have added the Heroku Postgres Addon, but don't know how to upload the Database. I can't use the Amazon Web Services as told in the devcenter since i don't have any Credit Card. Is there any way to upload the Database without AWS? Thank You and sorry for my bad English
You can dump your local database contents to a SQL file with pgdump. Then you can access your Heroku database from your local machine and upload your SQL using the psql command-line client. Get the access url like this from the Heroku command and put it into your client program.
heroku config | grep HEROKU_POSTGRESQL
Know this: sometimes Heroku migrates your data from one host machine to another. When they do that they change your access url. So retrieve that url again whenever you use the psql client.

Power Bi PostgreSQL data import error - The remote certificate is invalid according to the validation procedure.'"

I am trying to connect PostgreSQL database to Power Bi. Database is hosted on Heroku. I am getting the following error -
An error happened while reading data from the provider:
'The remote certificate is invalid according to the validation procedure.
I think i am getting this error because it needs "sslmode=require". but I am not sure how to proceed.
Can someone help me with this problem.
Thanks in advance.
These steps should help you connect to Power BI desktop via ODBC. Note, you should probably create a follower database in heroku so you're not using your production database credentials.
Download PostgreSQL ODBC driver and install. Note, be sure to check the GAC option during installation (https://www.postgresql.org/ftp/odbc/versions/msi/).
Restart computer.
Open Power BI and click "Get Data" button in the ribbon.
Click "Other" and then select "ODBC".
Choose "None" as the data source name.
Click the "Advanced options" and enter this connection string:
Driver={PostgreSQL Unicode};Server=HEROKU_HOST, where HEROKU_HOST is the "Host" from your heroku database credentials (example: ec2-xx-xxx-xx-xx.xxx.amazon.com).
On the next screen, enter the user name (user from heroku db credentials), password (password from heroku db credentials), and for connection string enter the following (with HEROKU_XXXX replaced with your info:
PORT=HEROKU_PORT;DATABASE=HEROKU_DATABASE;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;HOST=HEROKU_HOST;COMPATIBLE=2.2.3.0;USER ID=HEROKU_USER;PASSWORD=HEROKU_PASSWORD;SSLMODE=require
I don't use Heroku but had a similar problem with AWS and had to configure the db provider and certificates as described below. I would think that something similar is needed for Heroku.
I did some digging and found 2 possible solutions for Heroku:
Supply the additional settings sslmode=Require;Trust Server Certificate=true in the database connection. This does not seem to be an option with PowerBI, because even under "Advanced Settings" there is nowhere to provide these.
Download the certificate for you database as described here and then follow much the same process as I did below to register the certificate with Windows. If Heroku supplies a P7B (PKCS#7 or pfx (PKCS#12) format certificate you can register that with Windows without having to do the conversion I described.
My setup of the Npgsql provider and AWS Certificates
PowerBI and Excel support connections to Postgres using the Npgsql .NET Data Provider. This provider is not installed by default on Windows. Here's how to install it:
Download the appropriate .msi installer from the Npgsql releases page. The version you need depends on your version of Excel. I am running Office 365, which required version 4.0.x (I installed 4.0.10, download here).
Run the installer. During the install there is an option to install to the GAC which is switched off by default - you must select to have the files installed to the GAC.
Reboot your computer and you should be able to connect setup a Postgres connection in PowerBI or Excel.
AWS RDS Postgres - additional requirement
If you are connecting to a Postgres cluster running in AWS, when you attempt to connect to Postgres after installing the Npgsql provider you may get an error saying:
"The remote certificate is invalid according to the validation procedure"
Here's how to fix it:
Download the public keys for AWS RDS regions: https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
Convert the bundle to a Windows certificate in P7B/PKCS#7 format. There are many ways to do this, and easy one is to use https://www.sslshopper.com/ssl-converter.html.
In Windows, search for the "Manage User Certificates" utility and open it.
Right-click on "Trusted Root Certificate Authorities", "All Tasks", "Import..."
Select the .p7b file which was the output of converting the AWS keys to P7B format.
Choose to place all certificates in the Trusted Root Certification Authorities store.
You will probably have to confirm for each certificate - there is one per AWS region
You should now be able to connect to your AWS RDS Postgres database from PowerBI or Excel.
You need to check if the host based authentication in your postgres database is allowing this from connection from POWERBI.
[https://www.postgresql.org/docs/current/auth-pg-hba-conf.html][1]
The file is usually available in the postgres data folder and the structure is like below. Make sure the client host, username have the right permissions to access the database.
local database user auth-method [auth-options]
Note: If you are using a cluster manager like patroni, the pg_hba.conf file will be overwritten by Patroni every time you edit it. you will have to edit this configuration from the patronictl command.

2FA on phpmyadmin 4.8.4

I am trying to implement Two factor authentication (2FA) on phpmyadmin. Conifguration Storage has been setup and corresponding user has been created. However, when I go to Settings > Two Factor Authentication and select the Authentication Application (2FA) option, phpmyadmin throws the following error :
Error in processing request
Error code: 500
Error text: error (rejected)
It seems that the connection to server has been lost. Please check your network connectivity and server status.
If anyone has implemented or faced the issue, kindly help me resolve the same.
Is there any active firewall rules? Once I had a phpmyadmin on AWS ec2 and I was using AWS security groups, by only letting 3306 open I wasn't able to activate 2fa.

JDBC Connection times out in deployed web app with hosting service

I am using JDBC to create a connection to an MS SQL Server Database. The same code and connection string works fine on a number of platforms and in particular in my spring MVC Web Application.
After deploying the web application to a remote tomcat hosting service, everything appears to work fine in the code except that the database connection times out.
"com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host <IP Address>, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."
The hosting company says I must provide the exact steps to recreate the problem which may not be ideal. The only thing I can think of is to write another cut down application that connects to a different db with different credentials and test that in dev and deploy and then email them the war so they can deploy it and test it in their own environment.
Does anyone know of reasons why this might happen with a hosting service, like blocking the database response for some reason? Or is this very unlikely and should I assume that I am doing something wrong and persevere in understanding what might be different between my dev app and deployed app that could cause this timeout. Not that I can think of anything.
I don't want to take all that time if there is a common reason why this might happen that someone could point me to.
Thank you.

Failed to configure Release Management service user. Error: The remote server returned an error: (401) Unauthorized

I have tried to configure release management to work across different servers with untrusted domains using the steps described in the below article.
http://blogs.msdn.com/b/visualstudioalm/archive/2013/12/12/configuring-release-management-to-work-across-untrusted.aspx
But when I tried to configure RM agent with ghost account, it was throwing error mentioned in the title. Please see the error screen attached..!!
I am searching for a solution for last few days...!!! Experts please help me.
Finally the issue has been resolved by logging in as shadow account. Changed RM server name with IP in MS deployment agent....!!
Thank you very much #Daniel Mann for the tips you have provided.
write it down as
Correct way:-
http://(server):(port)
Incorrect way:-
http://(server):(port)/ReleaseManagement
Do not write "/ReleaseManagement/" or any other URL segments after .
This will solve your problem.
Logging in as the shadow account may not be possible depending on how you setup the service account. Release Management site uses windows authentication so if you setup your credentials in Credential Manager on the agent server that will work. Just specify the fully qualified domain name for your Release Management server and your domain credentials for the RM server's domain.

Resources