Make PostgreSQL listen to Google Data Studio - postgresql

I'm trying to connect one of my databases to Google Data Studio but I keep getting the following error:
Unable to reach the host.
I read the help page and already added the necessary IP addresses to the pg_hba.conf file this way:
hostnossl google_data_studio all 216.239.32.0/19 md5
That is just an example, but I have added all IP addresses required for the connection, 12 in total.
The connection description in Google's help pages shows these connections are non SSL (That's why I set it to hostnossl)
I've also restarted the postgresql service.

"Unable to reach the host" is a Google Data Studio error message, not a PostgreSQL message. PostgreSQL settings are irrelevant at this point. You are not reaching the server at all.
Since this just became a networking and settings issue for Google, I'm voting to close.

Related

Unable to connect PostgreSQL(pgAdmin 4) to the Google Cloud Platform

I have instance on Google Cloud Platform and I'm trying to connect it to the pgAdmin 4.
So here is my postgresql.conf
So I've tried the following:
I've wrote the instance ip as well as the username and password.
And I get the following error:
I've added my IP Address on cloud instance, but this didn't help as well.
Is there something else what I can try?
Posting this as a community wiki as this is based on the comments shared by #AdrianKlaver:
Given that you get a timeout expired error, which generally means a firewall blocked the connection, this is likely to be an issue on the port 5432 not being open to external access, so if you change that this might work.
NOTE: Just remember that you once you do this you will have opened the database to public access as determined by the IP's you allow in. Make sure your pg_hba.conf and role security are sufficient to deal with this. You can find more information on how to set this up by following both of this documenation links for Client Auth and to Create Roles

Does the fact I'm running a VM alter the whitelisting status of my regular ip address?

Our dev ops team have whitelisted my home ip address so that I can connect to our Postgres database on Azure. I am able to connect to our Azure database due to this.
Today I set up a VM in order to run Docker. I am running a container for RStudio which is an app that, among many other things, allows me to connect to our database using ODBC.
After configuring the odbcinst and odbc.ini files I believe that those are configured correctly because when I try to connect I get the following error:
Error: nanodbc/nanodbc.cpp:983: 00000: FATAL: SSL connection is required. Please specify SSL options and retry.
Thus I think that my odbc set up is correct because this error suggests my connection setting are fine, it's just that Azure will not allow it without SSL.
Searching that error message took me to this SO post with the following accepted answer:
By default, Azure Database for PostgreSQL enforces SSL connections between your server and your client applications to protect against MITM (man in the middle) attacks. This is done to make the connection to your server as secure as possible.
Although not recommended, you have the option to disable requiring SSL for connecting to your server if your client application does not support SSL connectivity. Please check How to Configure SSL Connectivity for your Postgres server in Azure for more details. You can disable requiring SSL connections from either the portal or using CLI. Note that Azure does not recommend disabling requiring SSL connections when connecting to your server.
My question is, if I am already able to connect to our database outside of my VM due to my home IP being whitelisted and just using a Postgres Driver with Dbeaver SQL client, is there anything I can do to connect from within my VM?
I can get my VMs ip address but I suspect (am not sure) if sending hat to our developers to whitelist would work?
Is there a prescribed course of action here?
I added this parameter to my .odbc.ini file and was able to connect:
sslmode=require
From Azure Postgres documentation, this parameter may take on different permutations depending on the context
"for example "ssl=true" or "sslmode=require" or "sslmode=required" and other variations"

MySQL Workbench cannot connect from home to Google Cloud SQL

I cannot connect to my Google Cloud SQL database from my Macbook Pro using MySQL Workbench.
I have read the help file here:
https://cloud.google.com/sql/docs/mysql/admin-tools
I have added an authorized IP address for my IP per
https://cloud.google.com/sql/docs/mysql/configure-ip#add
I created a user for the database with it set to allow to connect from any host. I get the error "Can't connect to MySQL server on 'XX.XXX.XX.XXX' (60)
I have also attempted to telnet and get a consistent error that I am unable to connect to the remote host
As far as I know, I've followed all the steps but it really seems I'm getting blocked even before the server. I am trying to connect from home and I don't believe my home firewall is blocking things. I am wondering if there's something I need to open up on the GCE firewall but I have successfully connected to this database from other outside tools (e.g., Zapier).
Your best action right now would be to create a proxy with public IP address.
https://cloud.google.com/sql/docs/mysql/connect-external-app
This link will walk you through that process. If this doesn’t solve your issue, then taking your question to ServerFault (Stackoverflow sister site) might give you a better idea of how to fix your issue.

AWS RDS Postgresql Pgadmin - Server doesn't listen

I followed the aws tutorial found here.
Everything went smoothly up until connecting to the postgresql instance via pgadmin.
I entered the appropriate user/pw info and copy/pasted the address of the db appropriately.
The port is indeed 5432 on my aws dashboard.
I am receiving the following error message:
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Operation timed out Is the server running on host "my_database_name.some_stuff.us-west-2.rds.amazonaws.com" (52.10.228.18) and accepting TCP/IP connections on port 5432?
If you encounter this message, please check if the server you're trying to contact is actually running PostgreSQL on the given port. Test if you have network connectivity from your client to the server host using ping or equivalent tools. Is your network / VPN / SSH tunnel / firewall configured correctly?
For security reasons, PostgreSQL does not listen on all available IP addresses on the server machine initially. In order to access the server over the network, you need to enable listening on the address first.
For PostgreSQL servers starting with version 8.0, this is controlled using the "listen_addresses" parameter in the postgresql.conf file. Here, you can enter a list of IP addresses the server should listen on, or simply use '*' to listen on all available IP addresses. For earlier servers (Version 7.3 or 7.4), you'll need to set the "tcpip_socket" parameter to 'true'.
You can use the postgresql.conf editor that is built into pgAdmin III to edit the postgresql.conf configuration file. After changing this file, you need to restart the server process to make the setting effective.
If you double-checked your configuration but still get this error message, it's still unlikely that you encounter a fatal PostgreSQL misbehaviour. You probably have some low level network connectivity problems (e.g. firewall configuration). Please check this thoroughly before reporting a bug to the PostgreSQL community.
Step 1
You are getting the same dialog I was seeing above. Crap!
Step 2
Go to your RDS instances
Step 3
Go to your security groups
Step 4
If your account was like mine you see this text:
Your account does not support the EC2-Classic Platform in this region.
DB Security Groups are only needed when the EC2-Classic Platform is supported.
Instead, use VPC Security Groups to control access to your DB Instances.
Go to the EC2 Console to view and manage your VPC Security Groups.
For more information, see AWS Documentation on Supported Platforms and Using RDS in VPC.
Step 5 Go back and check your RDS security group name (RDS->instances right click your instance). You will see something like Security GroupsList of VPC Security Groups associated with this DB Instance.
You will see something like:
default (sg-********) ( active )
Step 6 In your VPC security groups find your sg-******** that matches your database. Right click that. Edit inbound/outbound rules to add postgresql.
Try to connect again.
This solved my problem.
If this does not solve your problem I am very sorry, but I hope this documentation brings me some debugging karma.
go to AWS services in security group click on the security group id . from the "actions" button click on "edit inbound roles" and then change the "source" to "my ip"

Is it possible to see connection attempts to a Google Cloud SQL instance?

We are currently encountering the following error when trying to connect to a Cloud SQL instance: Lost connection to MySQL server at 'reading initial communication packet', system error: 0.
This is a familiar error, and as detailed here usually means the IP address needs to be whitelisted. However, we believe we have done so.
Is there a way to see connection attempts and their IP addresses that have been made (and refused) to the Cloud SQL instance?
Currently we don't expose that information but it is something we would like fix. :-)
According to #Razvan, as of September 2014, this information isn't exposed.
We ended up using CIDR blocks to search the space and find the actual IP address. This is unsatisfying, obviously, but it's a way to pin down the problem.
If other people want to sanity check that the problem is their IP is being refused, you can add 0.0.0.0/0 in order to accept all ranges and try to connect. If it works, you know what is the problem.
Be absolutely sure to remove this as an accepted range, after you are done, however!
Figured I might help someone who stumbles here.
Had exactly the same issue essentially trying to connect to a GCP SQL instance from a hosting provider.
Whitelist the IP address that is shown in my cpanel and it will not connect. (It used to, but the provider made some changes with their infrastructure lately and it stopped working)
put 0.0.0.0/0 in my Cloud Platform whitelist and it connects no problem.
So now I know that my cpanel IP is not the IP trying to connect to GCP.
After some hair pulling (figured that the bare metal server had a different IP than my cpanel IP, it did, but this also didn't work.)
finally tried the IP address for the name servers that point to my domain and bam. All is good.
If you are facing this issue, try your name server (usually something like NS1.hostingprovider.com etc..). I put both the NS1 and NS2 ip's in the whitelist and we are working fine.