Question

Remote access to PostgreSQL with pgAdmin

I can’t access remotely to a PostgreSQL, with pgAdmin database installed on an Ubuntu 16.04 droplet, with the Wordpress one install.

I would like to import a dump file, with the database settings from my local computer.

In the postgresql.conf file I have set:

listen_addresses = ‘*’

Running SHOW listen_addresses; I get localhost (1 row)

and in the pg_hba.conf one:

host all all 0.0.0.0/0 md5

But each time, that I try to connect from pgAdmin at my local computer I get this message: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host “139.59.151.107” and accepting TCP/IP connections on port 5432?

Any help would be much appreciated. Thanks in advance, Aleix Alcover

Show comments

Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Jonathan Tittle
DigitalOcean Employee
DigitalOcean Employee badge
June 20, 2017
Accepted Answer

@aleixalcover

When doing a port scan on 139.59.151.107, only ports 22 and 80 seem to be open, so if you need to connect remotely, you’d need to open port 5432 in the firewall to be able to connect.

Since you’re on Ubuntu, you can do this with ufw using:

ufw allow 5432/tcp

Let me know if that helps :-).

This comment has been deleted

    I have what seems to be a similar problem. In my case, I am using centos 7. I followed these steps to configure postgres on the remote server: sudo -i -u root

    echo "listen_addresses = ''" /etc/postgresql//main/postgresql.conf

    echo ‘host all all 0.0.0.0/0 md5’ /etc/postgresql/*/main/pg_hba.conf

    sudo systemctl restart postgresql

    However, when I try connecting to pgadmin4 on my local computer, I get the following error:

    Unable to connect to server:

    could not connect to server: Connection refused Is the server running on host “159.89.237.166” and accepting TCP/IP connections on port 5432?

    What do I do? I would greatly appreciate your help with this. Is there a command for Centos7 similar to “ufw allow 5432/tcp”? Or, is my problem something else (perhaps, in how I tried to configure postregres)?

    Thanks in advance!

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    card icon
    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Sign up
    card icon
    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

    Learn more
    card icon
    Become a contributor

    You get paid; we donate to tech nonprofits.

    Learn more
    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

    Learn more ->
    DigitalOcean Cloud Control Panel
    Get started for free

    Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

    New accounts only. By submitting your email you agree to our Privacy Policy.

    © 2023 DigitalOcean, LLC.