how to allow remote access to postgresql 11 (CentOS 7)?
I tried below:
/var/lib/pgsql/data
== postgresql.conf ==
listen_addresses = '*'
== pg_hba.conf ==
host all all 0.0.0.0/0 md5
local all all trust
host all all 0.0.0.0/0 trust
I also allowed port 5432 in firewalld and iptables
but still unable to access it from my notebook (10.100.100.188)..
anybody has experienced on this?
thanks a lot in advance
Regards
Don
Related
I'm trying to run a PostgreSQL database on a Docker container while allowing outside connections to it. I am using the "official" PostgreSQL Docker image (version 13).
After running the image, exposing its 5432 port, and mapping the container's 5432 port to the host's 5432 port I am greeted with the following error when trying to connect to it:
Fatal error: np pg_hba.conf entry for host "my_ip", user "admin", database "postgres", no encryption.
I've looked everywhere for a solution but all the answers are the same, so I will write here what has been suggested and I already did (or existed already):
The line: listen_addresses = '*' is in the file postgresql.conf.
The line host all all 0.0.0.0/0 md5 is in the file pg_hba.conf.
Ran the image with --expose 5432 and -p 5432:5432.
I've also tried adding the lines: host all all ::1/128 md5 && host all postgres 127.0.0.1/32 md5 in pg_hba.conf (with AND without host all all 0.0.0.0/0 md5).
I'm at a loss of what to do or try next - can anyone please suggest something to solve this pickle?
Thanks in advance!
I have the following lines in pg_hba.conf. Postgres is installed on a Windows server.
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
#host all all myip 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 would like to allow connection only from one more public IP address. How can I achieve that? As soon as I enable the above line IP: Postgres doesn't start.
Looking for some guidance.
To open the port 5432 edit your /Program Files/PostgreSQL/10/data/postgresql.conf and change
# Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
In /Program Files/PostgreSQL/10/data/pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/0 md5
Now restate the Postgres server use cmd
pg_ctl -D "C:\Program Files\PostgreSQL\10\data" restart
I run postgres on several Windows servers (Windows Server 2012 R2, Windows Server 2016) as a part of a commercial framework running on an Apache tomcat webserver. The local connection worked fine. However, I want the same postgres server to be accessible for another framework (Cakephp) on another server (Red Hat Enterprise Linux) on the same server farm. This used to work until I upgraded to postgres 9. Now I had to upgrade to postgres 10. No matter what I tried, I failed.
Here is what I did to solve the problem:
Find your local postgres configuration files. They are usually in the same directory as the postgres tablespace, in my case:
d:\PG10Data\postgresql.conf.
This file has to contain the following lines:
# - Connection Settings:
listen_addresses = '*' # what IP addresses/interfaces to listen on
port = 5432
The next file to be modified is the pg_hba.conf (hba = host based access):
# TYPE DATABASE USER ADDRESS METHOD
# some sample entries:
# this will open UP ALL REMOTE IPv4 connections, do not open up permanently
host all all 0.0.0.0/0 md5
# only 1 database for 1 user from 1 IPv4 address:
host yourdatabasename yourusername 10.15.17.13/32 md5
# don not forget the "/32", otherwise the postgres server will not start up!
After editing these files, restart the postgres server.
You can run
netstat -a -n | findstr 5432
to see if the postgres listener is running.
You can also run the following to test connectivity from the Windows command prompt:
psql -Uyourusername -dyourdatabasename -p5432 -hlocalhost
This should work at any time. The next level will be to use your computer's local IPv4 address. This you can find out with
ipconfig
This will tell you your local IPv4 address. Use this in the following command:
psql -Uyourusername -dyourdatabasename -p5432 -hyourlocalip
My problem was, this command failed. Since I ran it directly on my server, it could not be the local Windows firewall.
The solution:
There is a 2nd configuration file:
d:\PG10Data\postgresql.auto.conf
The file starts ominously with the following 2 lines:
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command
And it ends:
listen_addresses = 'localhost'
I tried the ALTER SYSTEM command when I was logged on locally as postgres via psql, but no success.
In the end I turned cheeky and changed the entry in d:\PG10Data\postgresql.auto.conf to;
listen_addresses = '*'
Bingo! After a postgres restart, remote access worked like a charm on both Windows servers.
N. B. Don't forget the Windows Firewall: Open port 5432 for remote access. Also check there are no firewalls in the network the block access to port 5432 from your remote client.
It would be nice if someone were able to tell me how I should have changed the parameter without editing the postgresql.auto.conf, but at least both of my framesworks - both on the local and the remote server - are working.
That is incorrect syntax: myip is not an IP address, and the /32 after it is missing.
From many days i'm trying to set the hosting on my postgreSQL. I try many solution but no one works. The version of my postgres is 9.6 for windows 32 bit with pgAdmin 4.
I've set in my pg_hba.conf with many type of option but non one work. Now it looks like this.
# IPv4 local connections:
host all all 127.0.0.1/32 #authmethodhost#
host all all 0.0.0.0/0 #authmethodhost#
# IPv6 local connections:
host all all ::1/128 #authmethodhost#
I've tried md5, trust.
thepostgresql.conf is already set like:
listen_addresses = '*'
I don't know how I can obtain the postgresql hosting
(the server work right in local host, the port is right set, the driver is installed).
This is the error message:
FATAL: no entry in pg_hba.conf for the guest "MY.IP.AD.DRS",
user "myadmin", "mydatabase" database, SSL is not enabled
Thanks.
I use a Windows 10 machine with Virtualbox 5.0.16 in which Ubuntu 15.10 is running. The network adapter is a Bridged one with the name set to Intel(R) Dual Band Wireless-AS 3165. The promiscuous-Mode is set to allow all VMs and the host and the underlying checkbox is checked (cable connected).
In this Ubuntu, I run a PostgreSQL 9.4.5 instance in which I configured both the postgresql.conf and pg_hba.conf files.
In the postgresql.conf file, I have well set this line:
listen_addresses = '*'
And in the pg_hba.conf, I have following lines at the bottom:
# 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
host all all ::1/128 md5
host all all ::/0 md5
host all all 192.168.1.13 md5
host all all 0.0.0.0/0 md5
Currently, the ip address of my host machine is (ipconfig command and wireless) 192.168.1.13 and the guest machine is (ifconfig command) 192.168.1.4
When using pgadmin from the host machine to connect to the guest machine, I get following message: FATAL: no pg_hba.conf entry for host "192.168.1.13", user "postgres", database "postgres", SSL off
I tried to connect to my host to guest via ssh but I get a "Network error: Connection refused" message. Maybe this is a key insight of my issue?
The ping works in both directions.
Thanks to #DanielVérité.
The command show hba_file showed me the pg_hba I was actually editing was not the right one. I edited the one in /etc/postgresql/9.4/main folder while the one used by postgreSQL is /opt/PostgreSQL/9.4/data
I have installed Postgres 8.4 on Centos 6.4 64 bit by yum. I want to manage Postgres Databases with phpPgAdmin-5.0.4-1 installed by yun too (like MySQL and phpMyadmmin)
After install phpPgAdmin-5.0.4-1 I cannot login to phpPgAdmin by access 192.168.7.4/phpPgAdmin/ (192.168.7.4 is my Centos server), it always says "Login failed" although I'm sure that I enter username (postgres) and password right
Here are my information, hope you can help :
netstat -tupln | grep postmaster
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 771/postmaster
tcp 0 0 :::5432 :::* LISTEN 771/postmaster
/etc/phpPgAdmin/config.inc.php
$conf['servers'][0]['desc'] = 'PostgreSQL';
$conf['servers'][0]['host'] = '192.168.7.4';
$conf['extra_login_security'] = false;
/var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
/var/lib/pgsql/data/pg_hba.conf
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
Thanks in advance.
Your setup if fine except for pg_hba.conf which lacks an entry for 192.168.7.4.
Consider adding it and reload the postgresql service:
host all all 192.168.7.4/32 md5
I tried the above solution but still got the 'Login Failed' message. To resolve, I had to ensure IPv6 is set to password in the pg_hba.conf file. So do: vi /var/lib/pgsql/9.4/data/pg_hba.conf and edit accordingly. Then restart both httpd & postgresql (whatever the version you are using)