AWS RDS for PostgreSQL cannot be connected after several hours - postgresql

I created several instances of RDS with PostgreSQL and get the same problems:
I can connect to all of them right after creating the instances.
After several hours (I stop working on it, turn off my laptop), I cannot connect to any of them again.
I use DBeaver for the connections, the error show is "Connection attempt timed out."
I attached the information of the
. Hope someone can help me with this problem. Thank you in advance.

Finally, I found the answer for my problem. For the error of "connection timeout", one of the reasons can be from the security settings. Although I set it as public when creating the RDS instance, the instance is attached with a private VPC security group which is not exposed public.
We can attach the RDS instance with a public security group inside the VPC (I don't think it is a good setting, just for the beginner in AWS like me) as below:
from Services, select EC2, select Security Groups in the left panel.
click "Create Security Group" button.
in the dialog, enter the name for the Group, e.g "postgres-public-access"
in the dialog, click "Add Rule" button.
In the "Type" column, select "PostgreSQL" or other types of RDS instances (or you can input the port of your RDS instance, usually it is 5432 for Postgres).
In the "Source" column, enter "0.0.0.0/0".
Click "Save" button.
from Services, select RDS, select the RDS instance, click "Modify" button.
In "Network & Security", "Security group", select the VPC Security Group you just created, in my case, it is "postgres-public-access".
Click "Continue" button.
Now you can go ahead and connect with your database everywhere.

I had to add/edit a rule to the VPC to allow connections from All sources.
Steps:
Go to DB > Connectivity & security > click on VPC(vpc-
Under Security > Security Groups > open sg-[something] for which VPC
ID matches the DB VPC
Inbound Rules > Edit Rules > Change Source to anywhere
So it seems that even when creating the DB and selecting allow public access, it only includes the traffic from withing the VPC. By doing the above steps you can allow access to all sources.

I just followed the guide: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
Run through the typical things:
Make sure the Database is Public! Check in the AWS Website Console, if its Private make it public.
Check you have the Firewall port open for the software and the port you're trying to connect through.
When you create a dB in RDS a Security Group is created automatically with the Rule All, All:
You can add a rule for TCP Port 5432, like I have above.
Check Username/Password - sometimes incorrect ones get cached.
Try to ping the dB to see if its a internet connection problem.

I faced the same issue and it end up because of the VPN am using, when i disconnected the VPN i apply to connect.

Select DB -> Modify -> Connectivity-> Save

Related

Access non-public PostgreSQL DB from Tableau Desktop through Tableau Server

Reading through the documentation of Tableau Server I was not able to determine if the following works:
I have set-up Tableau Server 2020.4.0 along with the PostgreSQL
driver
I added a connection to an internal, i.e. non-public, PostgreSQL DB via Tableau Server
I can access the PostgreSQL via logging in to Tableau Server just fine
I am also able to connect to the Tableau Server through Tableau Desktop BUT I cannot connect to the PostgreSQL as it is not directly accessible from the client machine running Tableau Desktop.
Is there a way to access this non-public PostgreSQL database connected to Tableau Server from Tableau Desktop through Tableau Server?
If the server is accessible via SSH then you can set up a port forwarding tunnel.
ssh -L 127.0.0.1:5432:postgres.example.com:5432 tableau.example.com
Then in the datasource within Tableau Desktop change the host to 127.0.0.1 from postgres.example.com. If there are SSL errors you may want to add an entry to your /etc/hosts file and not change the hostname.
sudo echo '127.0.0.1 postgres.example.com' >> /etc/hosts
Answering my own question and following #matt_black's comment it is indeed possible to access and use published Datasources from Tableau Desktop which are not directly accessible.
For that you need to login to the Tableau-Server UI (not TSM via 8850), create a Workbook, click on "Datasource" (bottom left hand corner) add a single or multiple connections and then head back to any "Sheet" Tab (also bottom left hand corner).
At this point it is recommended to save the Workbook as "Template", i.e. "my_published_datasoure_template" – explanation follows.
After saving the Workbook you need to hover over the Datasource-Icon in the "Data" Tab and click on the appearing dropdown-arrow to publish the Datasource.
It needs to be mentioned, that once a Datasources has been published this way it asks you to update the workbook right afterwards which you must deny in order to be able to edit the Datasources of the workbook afterwards.
If you need to edit the Datasource at a later point be sure to delete the previously published Datasource then edit and re-publish it.

Cannot connect to MongoDB Atlas Cluster: DNSHostNotFound

I created a new cluster in MongoDB Atlas but I can't connect to it thru the mongo shell.
C:\git_symphony\esp8266\SymphonySocket>mongo "mongodb+srv://<clustername>-gy7bf.azure.mongodb.net/test" --username <USERNAME>
DNSHostNotFound: Failed to look up service "":No records found for given DNS query.
try 'mongo --help' for more information
I tried switching regions but it didn't work. I've also tried using Compass on my mac but it just loads indefinitely when I try to connect. What could possibly be wrong?
Turns out, my ISP blocks all connections to MongoDB for some reason. I haven't contacted them yet, but I find this very silly as I racked my brains out trying to solve this when the problem wasn't at all in my control.
I also had this problem with Comcast Xfinity. DHCP sets DNS servers that would not lookup the mongodb connections. I'm running KDE Neon Linux (Ubuntu 18.04). In order to get things working I had to supersede the domain-name-servers supplied through comcast. I used Google's public DNS, but there are others that can be used. I had to edit (you'll need root permissions) the /etc/dhcp/dhclient.conf file, and added to following line:
supersede domain-name-servers 8.8.8.8, 8.8.4.4;
I hope this helps somebody, took me too long to figure it out. :-)
I just found this post by M. Brandao with the fix for Windows users:
Open the Control Panel.
Click View network status and tasks
Click Change adapter settings on the left portion of the window.
Double-click the icon for the Internet connection you're using.
Click the Properties button.
Click and highlight Internet Protocol Version 4 (TCP/IPv4) and click
Properties.
If not already selected, select the Use the following DNS server
addresses option.
Enter the new DNS addresses (see above) and click OK and close out of all otherwindows.
Have you whitelisted your IP address ? IP whitelisting is important otherwise it will not connect.
Have you created this cluster recently and is it in the europe region ?
Is the cluster properly deployed or you are experiencing any issue in the deployment of the cluster ?

Connecting to Database (Postgres AWS RDS)

I am following the tutorial on how to set up and connect a PostgreSQL server on AWS found HERE
When I try to sign in on workbench, I get this message:
At first I thought it was because my DB instance was not available yet, so I waited until it finished backing up. This did not seem to work as I am still getting this message. I will appreciate assistance on this.
Have you created a secutiry group and allow databases connection port?
From the docs:
VPC Security Group(s): Select Create New Security Group. This will
create a security group that will allow connection from the IP address
of the device you are currently using, to the database created.

My Google cloud instance always in Runnable state and going to running state

I have created a google cloud sql instance.Following are the configurations set:
IPv4 address -> 173.194.247.217
IPv6 address ->2001:4860:4864:1:3f64:544:3d9d:32ca
Database version -> MySQL 5.5
Region-> Asia
Backup window-> 2:30 AM — 6:30 AM
Binary log-> Disabled
File system replication-> Synchronous
Preferred location-> None
Tier-> D0
Pricing plan-> Package
My problem is that the instance is always in RUNNABLE state, even after restarting. Also, I have changed the Activation Policy to "always ON".
Due to this, I am not able to ping the the IPv4 address (173.194.247.217) and so not also able to connect via mysql-client or similar application.
Please Help!!
In order to connect with a Cloud SQL instance via IP, first a password has to be defined for the root account, and in order to do that, you must limit the IPs (either individual (/32) IPs, or whole IP ranges) that can connect to the instance. Therefore:
1: Go to your Cloud SQL instance in the Developers Console, and click "ACCESS CONTROL" at the top of the page;
2: In the Authorized Networks (Optional) section, click "Add Authorized Network", and enter at least the sub-net you'll be connecting from;
3: In the Set Root Password section, enter a strong password, then click the "Set" button to the right. Lastly, save your changes.

SQL Studio Management - How to run queries across multiple servers

My 2 server both use SQL Server 2008 R2
I have my local SQL server and also an Amazon machine running an instance of SQL-Server there.
I'm able to connect from my local machine to that Amazon SQL using the standard 10.10.10.10, 1433 connection from my local Management Studio.
What i need to do now is to run a query that says ..tells me what records I have locally that are not on the Amazon server right now.
Something like:
SELECT *
FROM [LOCAL].dbo.Table1
WHERE Field1 NOT IN
(SELECT Field1 FROM [AMAZON].Database1.dbo.Table1)
================================
Question:
I don't know how to write the "AMAZON" location on the Query window itself, since it's running on a different server.
Any help is truly appreciated !!!
You have to configure AMAZON Server as LINKED Server on your local machine. If you name it "AMAZON" - you query will work exactly as you wrote.
In SSMS, \Server Objects\Linked Servers. Right click, 'new linked server'. Name your server, and choose 'SQL server' radio button. Because I was authorized user on both machines with windows credentials, I selected 'Be made using the login's current security context' radio button under the security tab, and did not even have to fool with the local/remote user mappings.
In order to be able to run queries across multiples servers, a link (linked Server) must be established between the 2 Servers. To create a linked server,
Navigate to the Linked Server Sub-folder under the Server Object folders
Right Click on the Linked Server Folder
Click on New Linked Server
Supply the Connection Strings for the Server
Name your Linked Server.
You can now use the full object qualification (LinkedServer.Database.tableOwner.Table) to access the objects.
Good Luck !
You should open your registered server window and create a group for your servers. then you right click the group name and select new query (Or select several servers in that group). if you execute the query it will rung against the servers selected.