My docker container running on AWS EC2 is configured to allow traffic from only 172.17.0.0:5432. I'd like to change this to allow traffic from public IP addresses? Do I use 0.0.0.0:5432->5432/tcp?
How do I change this configuration? I'm ssh'd into aws ec2.
Context, I am running postgres on docker container / image in aws ec2. However, my connection request fails as the traffic is blocked from remote machines.
conn = psycopg2.connect(
host="204.xxx.xxx.xxx",
port="5432",
database="name_db",
user="postgres",
password="xxxxxxxxxx"
)
OperationalError: could not connect to server: Connection refused
Is the server running on host "204.xxx.xxx.xxx" and accepting
TCP/IP connections on port 5432?
have you created the appropriate rules for the AWS server that hosts the docker container?
Related
I have pgAdmin4 and PostgreSQL running inside Docker containers on a GCP virtual machine. I have already ingested data into PostgreSQL and I can access the tables and databases using pgcli. However, I am unable to connect to pgAdmin4. How can I connect to the pgAdmin4?
You will access pgadmin with your browser.
When you start up the pgadmin container, you should have configured a port mapping. Add a firewall rule to your VM's network configuration for this mapped port (for example, I've configured an ingress firewall rule for 15432 because I mapped 15432 to 80 in my docker config).
Example snippet from docker-compose:
ports:
- 15432:80
Assuming you have configured an external IP address, use the external IP address and the port number in your browser to access pgadmin. Like this, where XX.XX.XX.XXX is your external IP and 15432 was mapped to port 80:
http://XX.XX.XX.XXX:15432/login
I have a mongo on my host machine, and an ubuntu container which is also running on my machine. I want that container to connect to mongo.
I set as host url, my host ip from docker network : 172.17.0.1
and in the /etc/mongod.conf file I set the bindIp to 0.0.0.0
from the container, I can ping the host,but the mongo service is not accessible, I get that error :
Connecting to: mongodb://172.17.0.1:27017/directConnection=true&appName=mongosh+1.5.0
MongoServerSelectionError: connection timed out
More over, I can connect from host to the mongo service with that command :
mongosh mongodb://172.17.0.1:27017
Do you know why I can't access mongo service from my container ?
You can use host.docker.internal as reference to your host machine from the container. So mongo host.docker.internal:27017 should work.
From docker documentation:
I want to connect from a container to a service on the host
The host has a changing IP address (or none if you have no network access). We recommend that you connect to the special DNS name host.docker.internal which resolves to the internal IP address used by the host. This is for development purpose and does not work in a production environment outside of Docker Desktop.
On your local machine that has Mongo service is running, you can access by Mongo client because you expose the service at 127.0.0.1:27017.
However, it is not true if standing from your unbuntu container, there is no Mongo service is running at 172.0.0.1:27017 of the ubuntu container.
Docker-compose is the right tool for you to make containers communication to each other.
I am not able to connect the docker container using SQL developer. I used the docker desktop container internal ip ( ip a) and port number (docker port <container_name> ), but still getting the below error.
Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=nEnUfwk5Spaz8T7qS3vmCw==)
Here is my SQL Developer configuration:
The ip address and port aren't reachable from your host machine where SQL Developer is running.
See here where our Docker images are setup for you to simply connect via localhost:
https://hub.docker.com/r/gvenzl/oracle-xe
I am struggling to connect with pyCharm to a postgres instance running on amazon rds.
In host I plug in the Endpoint. I configure driver to be the jdbc jar file (external library).
Test connection says that the connection on port 5432 is refused: Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
On rds side:
For the security group I have an inboud rule for All traffic with source Anywhere
The VPC has DNS resolution and DNS hostnames enabled
VPC is publicly accessible
VPC classic link is enabled
I have two machines in amazon. web01 and db01. I installed PostgreSQL on db01, and added the elastic ip of web01 to the pg_hba.conf
host dbname username 64.210.245.155/32 md5
and restarted the postgresql service. Now in web01 I tried to connect to the elastic ip of db01
$ psql -h 64.210.255.222 -U user -d database
psql: could not connect to server: No route to host
Is the server running on host "64.210.255.222" and accepting
TCP/IP connections on port 5432?
I also added the elastic ip of web01 to db01's security group for inbound traffic. What am I doing wrong and how can I get web01 to connect to pg on db01?
To start with, you want to be connecting to the internal IP. You can use the DNS name if your elastic IP as it will resolve to an internal IP within AWS instead of using the elastic IP directly.
Secondly, all public IPs are assigned via NAT. If your service tries to listen to that IP address it will fail. Generally the best thing to do is listen to all IPs, unless you are using VPC and have control of the internal IP.
Lastly, you will provide access to the web security group within the db security group. Even if two instances are in the same security group, they will not be able to access each other unless the group is given access to itself.