Postgres pgAdmin: Unable to connect to server: timeout expired - postgresql

I'm trying to connect a local Postgres server to an AWS RDS instance. When I enter in the credentials:
I keep getting an error: Unable to connect to server: timeout expired
I searched and it seems to be an issue with the security group. I did the following but it didn't work: https://serverfault.com/questions/656079/unable-to-connect-to-public-postgresql-rds-instance

Based on the comments. The issue was that publicly accessible option in the RDS settings was disabled.

Here is some suggestions/troubleshooting steps,you can follow:
Make sure that RDS is in available state an publicly accessible. RDS instance should associated with public subnet.
2.RDS should be associated with some security group. Check rules associated with security group so that it allows traffic related to the source in and out of the DB instance. You can specify an IP address or a range of IP addresses related to source.
3.Network ACLs. Network ACLs act as a firewall for resources in a specific subnet in a VPC. If you use ACLs in your VPC, be sure that they have rules that allow inbound and outbound traffic to and from the DB instance.
Check with your local firewall setup to determine if your network allows traffic to and from the ports the DB instance uses for inbound and outbound communication.
Please refer this page. This might help you.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html

Based on Jonnel Salvador Dorotan comment on this video https://www.youtube.com/watch?v=3HPq12w-dww I was able to get it to work. Here is his comment pasted:
"For those who are getting this error: "... Connection timed out (0x0000274C/10060)", these are what I did to solve the problem:
Go to "Security group rules" (under "Connectivity & security")
Click the item "default" Security group
Click "Actions" > "Edit inbound rules" > "Add rule"
Select... Type: "All traffic", Source: "My IP", then click "Save rules"

Set inbound rules in aws to accept all traffic, select My Ip then save
Go to Modify database in aws then select security group under Network & Security. Select the security group identifier from the dropdown.

I had this same issue. In my case, my home IP had changed, and I needed to adjust the Inbound Rule for "My IP" as described in Maxime's answer.

Addition to some of the above suggestions, make sure the Route Table attached to your public subnet:
has been set as main route table. To do this: go to VPC dashboard in AWS console >> Select "Route tables" option from the left link >> Select your route table >> From the "Actions" button click on "Set main route table" from the dropdown menu
has the route for the Internet Gateway that you're using in your VPC. You can check this on the "Routes" tab in the lower pane of your route table.

In the case of IPV6, try adding IPV6 ALL in the outbound rules as well.

Related

GCP Add VPN Tunnels from one Peer VPN Gateway to another Peer VPN Gateway appears impossible; only the source VPN Gateway is available in Peer list

Within one project, I created two VPC networks, one in region us-central1 and one in region us-east1. Each has subnet 10.0.x.0/24. I know I could use VPC peering to connect these two subnets, however my goal is to verify I can setup a HA VPN connection between these two VPC networks.
Foreach VPC network I created an HA VPN gateway, named for their respective region: "vpn-gateway-central" and "vpn-gateway-east"; each has two public IP's for HA. I created two (one per each VPC) cloud routers for BGP use.
I fail when I try to create the VPN tunnels. My expectation based on available online tutorials (that have an older GCP UI) is that I create the tunnels in both directions, just like non-cloud VPN tunnels. From the central to the east, I attempt to create the tunnel in the "central" VPC, and I expect its remote peer(s) will be the set of IP's from the "east" VPC.
The GCP UI does something unexpected: It has me "SELECT PROJECT", and then it populates a drop-down for the "VPN gateway name" from which I select the peer. In this case, I would expect to see a list of VPN gateways that DO NOT exist within the VPC network from which I am starting. Thus, if I am starting from the "central" VPC network, then I expect to see the "east" VPC network in the "VPN gateway name". However, all I see is the VPN gateway name within the "central" region. The initiator and the peer IP's cannot be the same, but that is the result of making the only selection offered in the listbox "VPN gateway name".
I clearly cannot create this tunnel. Is this a bug in the new UI? Is this a beta? This GCP console UI has definitely changed from the ones I see in the online tutorials - where it appears to work (it exposes the remote VPN gateways, as one would intuitively expect, not the ones resident to the VPC network from which I am creating the tunnel).
This is my first VPN within GCP, so I'm likely missing something. However, in any case, if it's not broken, then at least it appears confusing. I will appreciate clarification/trick/workaround.
link to the GCP "Add VPN tunnels" dialogue where the unexpected list of VPN gateway names appears
I added another pic that shows the dialogue.
I didn't notice any issue regarding Cloud VPN from GCP.
To create a HA VPN between VPCs, this is the proper documentation.
In case you cannot create via UI, you can try to create it via gcloud commands, and you'll get more information about the issue that could be happening.
I recommend to check this, follow the guide and paste here the output of the gcloud commands if it fails.

Timeout expired: Connecting Azure Postgres using local pdAmin

I am using psql on Azure. While I am successfully able to connect it on CLI and using Python psycopg2 or other modules and library, I am facing issue connecting it to the pgadmin Web UI.
The process to connect to the Azure POSTGRES in pgadmin is as follows:
Click on Add New Server.
Provide Name under General tab.
Provide Host, Port, DB Name, Username, Password.
After clicking on Save, it always pops connection timeout error.
While with the above config I can connect to it in the python, create cursor and commit a query. Do we require additional settings to be done for connecting it to the pgadmin. I am new to cloud and not sure if there is some additional security checks like token access to be provided or something.
Please have a check that have you enabled your local public IP address in Postgres DB Firewall rules?
After I created the new DB and added my local public IP to Firewall rules, I can connect to DB by local pgAdmin successfully:
Configs:
Allow your IP address in Azure postgresDB Networking section. You can configure your VNET or firewall rules as needed.
Check if your organization allows your IP to be visible to Azure. In my case, I was able to connect only when I was not connected to organization VPN.
"Some network environments may not report the actual public-facing IP address needed to access your server. Contact your network administrator if adding your IP address does not allow access to your server."
Under settings. Click on Networking. you will find a link like '+ Add current client IP address ( 119.160.103.152 ) + Add 0.0.0.0 - 255.255.255.255' click on it and use 0.0.0.0 to allow all public ip addresses. Now try to connect.
enter image description here
Above answer is correct but look at he above link now option for public ip is under Network option.
Connected success fully after doing this.

Connectivity issue with AWS DMS with Postgresql on RDS

I have 2 Aws RDS instances,(Run on Postgresql). Both are on Different accounts and different regions. I want to set up data replication between them, using AWS DMS.
I tried doing VPC peering.
I saw the following video to enable VPC peering :-
https://www.youtube.com/watch?v=KmCEFGDTb8U
The Problem:-
When I try creating the AWS DMS service, I add the Hostname, Username and Password, etc for the source(Which exists on the other account), and when I hit Test Connection, I get the following error.
Test Endpoint failed: Application-Status: 1020912, Application-Message: Failed to connect Network error has occurred, Application-Detailed-Message: RetCode: SQL_ERROR SqlState: 08001 NativeError: 101 Message: [unixODBC]timeout expired ODBC general error.
To my surprise, I get a similar error when I hit the Test Connection for the Target RDS instance, which is in the same account. i.e.:-
Test Endpoint failed: Application-Status: 1020912, Application-Message: Cannot connect to ODBC provider Network error has occurred, Application-Detailed-Message: RetCode: SQL_ERROR SqlState: 08001 NativeError: 101 Message: [unixODBC]timeout expired ODBC general error.
Google suggests that we are having some sort of Firewall, but looking at the NACLs I can see we allow 0.0.0.0/0 for both the VPC's.
If you're attempting to access the private IP ranges in one IP from another IP, in addition to creating the VPC Peering connections, you'll have to:
create route table entries in both VPCs to route traffic to the remote VPC's IP range(s) through the Peering Connection,
allow connections within the security groups, both from the source CIDR range in the destination security group, and, if you're filtering outgoing connections from the source, also in it's outbound rules. Note that you can't use Security Group Id to allow this traffic because it doesn't apply to cross region peering;
allow the connection in the underyling software ( probably allowed by default ),
allow the network ACL to pass the traffic ( you've verified that's also allowed by default)
Since you're seeing timeouts, I'd suspect the security group rules. But, it could also be a bad route.
As suggested here https://aws.amazon.com/premiumsupport/knowledge-center/dms-endpoint-connectivity-failures/
When modifying the Replication Instance used to test connection to the Endpoint, take note of:
Private IP Address
VPC Security Group
Either change the Security Group to a suitable one or edit the Security Group being used adding an Inbound Rule to allow PostgreSQL traffic Type from the Private IP Address of the Replication Instance.
The below solution worked for me.
Create replication instance, then endpoints.
If the test endpoints fails - then ensure to pick up the private IP from the instance(if DMS replication instance and the DB are located within the same VPC) and add it to the inbound rules of the corresponding security ID.
If the VPC's are in different region, you might need VPC Peering to get this sorted.
Since I had both running in the same VPC, adding the private IP to inbound rules worked fine and the connection is successful.

connect to amazon RDS on scaleway server

I wanna try amazon RDS for my project, so I created micro instance in amazon AWS. I am new to AWS, I added my server IP to security group and VPC. I tried to connect from server:
psql -h digrin.asdada.us-west-2.rds.amazonaws.com -p 5432 -d digrin -U my_username -W
psql: could not connect to server: Connection timed out
Is the server running on host "digrin.asdada.us-west-2.rds.amazonaws.com" (54.71.212.12) and accepting
TCP/IP connections on port 5432?
I can login from localhost, so I was going through amazon AWS settings multiple times and added IP of server everywhere I thought might be causing problems. No luck.
Then I tried to login from another server, which IP I did not add anywhere to AWS and I did connect successfully - so my database is pulicly available.
So I thought my server provider is blocking 5432 port or something such. I created ticket with them (Scaleway) and this is what I got:
Hello,
Please understand that we do not provide support regarding software management / Firewall configuration.
On our end, nothing is locked network-wise on any port unless you modify your security group's configuration.
I don't understand where the issue could be. Any ideas?
Network access to your RDS instances is controlled by a security group which acts somewhat like a firewall. Rules can be crafted in security groups to allow other members of that security group to connect to each other, which is the default policy in the default security group. Thus because your RDS instance and your EC2 instance are members of the same security group they can communicate freely but nothing else outside of that group can communicate with either host.
An instance can be a member of more than one security group at a time and if there are rules allowing the traffic in any of the security groups for which the instance is a member then the traffic will be allowed. In the spirit of security I would suggest not opening more ports than necessary and would not recommend opening ports within the default security group as that would effectively make those ports accessible on all instances in that security group.
So, to allow access to your Scaleway host:
Create a new security group from the VPC console, add a rule to this group that allows the MySQL port to be accessed from the IP address of your Scaleway host (or from anywhere, depending on your level of security concerns)
Attach that security group to your database in addition to the default security group through the RDS console

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"