By sibeliusve
Hey!
I recently started developing my droplet, and I’m quite new to this. Im trying to establish a remote PostgreSQL connection through pgAdmin4. The problem is, when I try to connect through pgAdmin4 by going through the Add new server and clicking Save button, it does nothing, sort of freezes.
My droplet is running on Ubuntu 16.04, I followed an instruction on how to set up PostgreSQL on ubuntu 16.04 on Django, installed all the necessary components, set up an environment, and a project, to the point where I even managed to create a db and a table. I even edited the settings.py file:
DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.postgresql_psycopg2’, ‘NAME’: ‘…’, ‘USER’: ‘…’, ‘PASSWORD’: ‘…’, ‘HOST’: ‘127.0.0.1’, ‘PORT’: ‘5432’, I even added that to the end of the page: STATIC_ROOT = os.path.join(BASE_DIR, ‘static/’)
And, ofcourse changed the ALLOWED HOSTS = [‘…’] to with my droplet ip aswell.
Then I edited both postgresql.conf and pg_hba.conf aswell. The listen_address is set to ’ * ’ and it is uncommented
The pg_hba.conf file:
local all postgres peer
local all all peer
host all all 0.0.0.0/0 md5
host all all ::1/128 md5
I also allowed port 5432 through my firewall.
Any ideas why I can’t set up a connection with pgAdmin?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I would strongly recommend against setting up your database server to listen publicly as it can open you up to potential attacks or attempts to compromise your server.
Rather than making PostgreSQL configuration changes you can use the SSH Tunnel option in pgadmin. With this type of a connection you would add your ssh connection details (user/pass or user/key) and pgadmin will make an ssh connection to your server and then connect to your database as “localhost”.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.