Configure PostgreSQL to allow remote connection
By default PostgreSQL is configured to be bound to 'localhost'.
Here are the steps I used to set up Postgres in Mac OSX. If you wish to create a user without a password just take the -pwprompt off the command.
As we can see above port 5432
is bound to 127.0.0.1
. It means anyattempt to connect to the postgresql server from outside the machine will be refused.We can try hitting the port 5432
by using telnet.
- Backup the pghba.conf file by copying it to a different location or just rename it to.
- $ psql -U postgres postgres=# alter user postgres with password 'NEWPASSWORD'; postgresl=# q Reset the PostgreSQL password. If you don’t remember your PostgreSQL database password, you can follow the steps below to reset it to a new value: Change the authentication method in the PostgreSQL configuration file pghba.conf from md5 to trust.
- The OSX username PostgreSQL is used to run postgresql's postmaster process with limited access to the system. Postgres is the database superuser name created by the one click installer. The server doesn't listen message is a bit weird because password validation happens only after a connection is established so I would have expected you to get.
- 5 Uninstalling PostgreSQL: 5.2 Uninstalling PostgreSQL on a Mac System 5.2 Uninstalling PostgreSQL on a Mac System To uninstall PostgreSQL on a Mac system, assume the identity of an operating system superuser, and navigate into the folder in which the uninstaller resides.
Configuring postgresql.conf
In order to fix this issue we need to find postgresql.conf
. Indifferent systems it is located at different place. I usually search forit.
Open postgresql.conf
file and replace line
with Free dropstuff for mac.
Now restart postgresql server.
Here we can see that 'Local Address' for port 5432
has changed to 0.0.0.0
.
Configuring pg_hba.conf
Let's try to connect to remote postgresql server using 'psql'.
In order to fix it, open pg_hba.conf
and add following entry at thevery end.
The second entry is for IPv6 network.
Do not get confused by 'md5' option mentioned above. All it means isthat a password needs to be provided. If you want client to allowcollection without providing any password then change 'md5' to 'trust'and that will allow connection unconditionally.
Postgres App Mac
Restart postgresql server.
Uninstall Postgresql Mac
You should be able to see list of databases.
Mac Postgres Password Recovery
Now we are able to connect to postgresql server remotely.
Mac Postgres Password Manager
Please note that in the real world you should be using extra layer ofsecurity by using 'iptables'.