I'm trying to connect my RDS postgres SQL databade to my pgAdmin III to see the BBDD and add data but the connection launches the following one error:
pgAdmin message
My pg_hba.config have the following one configuration:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections: host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
and my postgresql.conf:
listen_addresses = '*'
port = 5432
max_connections = 100
I have configured the firewall rules in my windows desktop, for the pgadmin be able to communicate through TCP for the 5432 port.
I also Attach the variables of the connection:pgadmin connection
Thanks, If you can help me, I'll it grateful.
Check if your security group has an entry for port 5432 on TCP.
I leave my configuration of security group:
Group name:
awseb-e-ds3pmf8tx8-stack-AWSEBRDSDBSecurityGroup-G0BCKWC2QTGH
Group description:
Enable database access to Beanstalk application
Group ID:
sg-39ce5252
VPC ID:
vpc-ead84082
INBOUND:
Type:
All TCP
Protocol:
TCP
Port range:
0 - 65535
Source:
sg-d2fa6ab9 (awseb-e-ds3pmf8tx8-stack
OUTBOUND
Type:
All trafic
Protocol:
All
Port Range:
All
Destination:
0.0.0.0/0
Related
I'm trying to connect to host OS MySQL via host.docker.internal, I'm able to connect if i directly mention my internal IP in Laravel application hosted inside docker container.
OS / ENVIRONMENT:
Host operating system and version: MacOS Monterey 12.5.1
Docker desktop version: 4.12.0 (85629)
Docker desktop engine: Engine: 20.10.17
Docker desktop compose version: v2.10.2
Problem:
These are the steps i took to connect my Laravel application inside docker to my host OS MySQL. I successfully managed to connect my application via internal IP address of my Host OS, but the internal IP keep changing and its kind of getting dificult to keep changing the DB_HOST inside laravel .env each time the IP change. so i want to use host.docker.internal but i won't work.
Steps:
1: docker-compose down (Delete all the containers)
2: I removed the devilbox .env port HOST_PORT_MYSQL=
3: I changed the port of my host OS MySQL to 3306 and using sequel ace i successfully connected to mysql with these credentials
Host: 127.0.0.1
user: root
database: hanger
port: 3306
4: In order to connect from docker to my Host OS MySQL i had to edit my my.cnf file OR in this case created a new one for MySQL here the my.cnf
[mysqld]
bind_address = 0.0.0.0 # default is 127.0.0.1 Change to 0.0.0.0 to allow remote connections
5: Restarted the MySQL server and confirmed that MySQL can now listen to all IP's and NOT just localhost
6: used this command
netstat -anp tcp | grep 3306 OR netstat -ap tcp | grep -i "listen"
tcp4 0 0 127.0.0.1.3306 127.0.0.1.52469 ESTABLISHED
tcp4 0 0 127.0.0.1.52469 127.0.0.1.3306 ESTABLISHED
tcp4 0 0 127.0.0.1.3306 127.0.0.1.52468 ESTABLISHED
tcp4 0 0 127.0.0.1.52468 127.0.0.1.3306 ESTABLISHED
tcp4 0 0 127.0.0.1.3306 127.0.0.1.52464 ESTABLISHED
tcp4 0 0 127.0.0.1.52464 127.0.0.1.3306 ESTABLISHED
tcp4 0 0 *.3306 . LISTEN
tcp46 0 0 *.33060 . LISTEN
tcp4 0 0 192.168.18.190.3306 192.168.18.190.52566 TIME_WAIT
tcp4 0 0 192.168.18.190.3306 192.168.18.190.52567 TIME_WAIT
tcp4 0 0 192.168.18.190.3306 192.168.18.190.52568 TIME_WAIT
7: Once its confirmed that 3306 is listeing need to create a MySQL user which would be connected from other than localhost
8: In mysql shell i executed these queries, since I'm using MySQL 8.0.27 the creating user and granting previliges must be in seperate queries.
CREATE USER 'root'#'%' IDENTIFIED BY 'root'; // remember this root password we will use it in Laravel .env
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
9: To make sure the root#% user is created type
SELECT User, Host FROM mysql.user; there are two root users one with host set to localhost and second one is %
10: Now its time to Edit Laravel .env MySQL section
DB_CONNECTION=mysql
DB_HOST=192.168.18.190 // my host machine internal ip (host.docker.internal not working)
DB_PORT=3306
DB_DATABASE=hanger
DB_USERNAME=root
DB_PASSWORD=root
Note: my DB_HOST did not work with 127.0.0.1 OR host.docker.internal so i thought it may work with my local IP, which it did.
11: To find out my local IP on MAC go to system preferences > network > My wifi connection > advanced > TCP/IP > under IPv4 192.168.43.182
The thing I'm concerned about is that my local IP keep changing, and as per the documentation The following sections will give you the IP address and/or the CNAME where the host os can be reached from within a container. https://devilbox.readthedocs.io/en/latest/advanced/connect-to-host-os.html#docker-18-03-0-ce-and-docker-compose-1-20-1 The docker should be able to connect through host.docker.internal to my Host machine, which it does not and i don't know why. Can you please anyone please point me in the direction what should i do to figure out this issue ?
Don't know the exact reasoning why does it work on some mac machines and doesn't on some, but you can force docker to map host.docker.internal by adding "host.docker.internal:host-gateway" under extra_hosts in your docker-compose. You should be able to use it post this.
Same problem here, the "host.docker.internal" is for development purpose and does not work in a production environment outside of Docker Desktop.
https://docs.docker.com/desktop/networking/#use-cases-and-workarounds-for-all-platforms
Suggested solution:
The database port (typically 3306 for mysql, mariadb, etc.) must be available on the host, you must check the firewall and open the port.
If you use ufw, the command is the following:
sudo ufw allow 3306
Bind_address should be change in the database configuration.
Access to the file can be found in general: /etc/my.cnf
bind_address = 0.0.0.0
In your case you have already do this.
After that, you have to look at the IP address of the gateway of the docker bridge network and enter this value as the host access value of the database. This is usually the IP address: 172.17.0.1
To check the bridge network details run following command:
docker network inspect bridge
Result will be a JSON where you will find the IP of bridge gateway:
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
}
If everything is set up correctly, you can access the database on the host machine from the docker container.
I run on Windows 10
docker run -it --rm -e POSTGRES_PASSWORD=postgres -p5401:5432 postgres:12.3-alpine
it works fine. I can connect to PostgreSQL, create database etc, all is ok.
But when I run the same docker on my 2nd machine Windows 7 I receive
Could not connect to server: Connection refused (0x0000274D/10061) Is
the server running on host "localhost" (::1) and accepting TCP/IP
connections on port 5401?
What may be the reason? what to check?
That is pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all all md5
I would say the possible issues are:
1) The server has not actually been started in the Docker server.
Verify server is running.
2) Port 5401 is not visible to the client that is trying to connect.
Ping the port. Could be a firewall issue.
New to PostgreSQL and running PostgreSQL on windows
I have a PostgreSQL running locally on a remote machine and also a PostgreSQL on my laptop(win 10)(same LAN), trying to connect to the remote PostgreSQL from my laptop but getting the error
no pg_hba.conf entry for host "xxx.xxx.x.xxx", user "postgres", database "postgres", SSL off
I can telnet the remote machine with port 5432
telnet xxx.xxx.x.xxx 5432 is OK ,for testing purpose ,I have given all for the connection and also my PostgreSQL installation/configuration is default on my laptop and on the remote machine . Not sure how to dig the issue here, is there any issue of running services locally without specific ip is a problem?
when I run select(host(inet_server_add r())) my o/p is just ::1
My pg_hba file is as below ,
#IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all all md5
#IPv6 local connections:
host all all ::1/128 md5
#Allow replication connections from localhost, by a user with the
replication privilege.
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
I was working on our company's new API build for the last 6 months and when I was made aware of a problem with our existing system. I tried to access my local env again to try to debug and found my local DB locked down for an unknown reason with a password that was not root (the initial password I set). Now, I cannot log in at all to my local DB server and editing the pg_hba.conf file and restarting the server did nothing. It was still asking for a password. Any advice is greatly appreciated. specs and screenshot below:
Environment: Windows 10 Pro
Codebase Language: Elixir
DB: postgresql 10
Port: 5432
config :rog_api, RogApi.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "root",
database: "rog_api_local",
hostname: "localhost",
pool_size: 18
pg_hba.conf file:
# TYPE DATABASE USER ADDRESS METHOD
host all all all trust
# IPv4 local connections:
#host all all 127.0.0.1/32 md5
# IPv6 local connections:
#host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication all 127.0.0.1/32 md5
#host replication all ::1/128 md5
I'm running postgresql on a Vagrant centos 7.2 box on macOS. I have confirmed postgres is up and running on the Vagrant box on port 5432 by connecting to it using psql on the box itself. I am attempting to forward port 5432 on the Vagrant box to port 10001 on my host machine as follows:
config.vm.define "acc_db" do | acc_db |
acc_db.vm.box = "bento/centos-7.2"
acc_db.vm.hostname = "acc.db"
acc_db.vm.network :forwarded_port, guest: 5432, host: 10001
acc_db.vm.provision "shell",
inline: "yum upgrade -y -q --nogpgcheck"
acc_db.vm.provision "shell",
path: "install_postgres.sh"
I have altered my pg_hba.conf to bind to all ip addresses and allow password authentication, as below:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 ident
I have turned off the firewall but I am still unable to connect to postgres on port 10001 on the host machine:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.10001"?
How do I fix this so that port forwarding works?
I have seen https://gielberkers.com/fixing-vagrant-port-forwarding-osx-yosemite/ but haven't tried it as it involves touching files I'm unfamiliar with. Is it the correct approach? It looks like you have to explicitly allow every port you want to forward via Vagrant.
...connections on Unix domain socket "/tmp/.s.PGSQL.10001" means that you are not attempting a TCP/IP connection, so port forwarding cannot happen.
By default, psql use Unix domain sockets on unix-like OSes.
Use the -h option of psql to specify a host, presumably 127.0.0.1 if using IPv4.
Additionally, the PostgreSQL server must listen to the network interface to which the connection will be routed. By default, it listens only to localhost for security reasons.
Setting listen_addresses='*' in postgresql.conf makes it listen on all existing interfaces.