Remotely access postgresql database The 2019 Stack Overflow Developer Survey Results Are Inhow to create a postgres on NFS?How do I install pgAdmin III for postgreSQL 9.2?Cannot open portInteracting with PostgreSQL on remote server through SSH tunnel?postgresql broken after 14.04 despite succesful pg_upgradeCannot connect to Port 5432Stopping a postgresql instanceRunning two PostgreSQL servers in same Ubuntu machineHow do I solve a “server version mismatch” with pg_dump when I need BOTH PostgreSQL servers installed?could not connect to server: No such file or directory in PostgreSQLCan't access PostgreSQL after crash restart, reports dbus error

How to notate time signature switching consistently every measure

Does a dangling wire really electrocute me if I'm standing in water?

"as much details as you can remember"

Is an up-to-date browser secure on an out-of-date OS?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Is bread bad for ducks?

Who coined the term "madman theory"?

Why is the maximum length of OpenWrt’s root password 8 characters?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Is a "Democratic" Oligarchy-Style System Possible?

Can a flute soloist sit?

What is the meaning of the verb "bear" in this context?

Why hard-Brexiteers don't insist on a hard border to prevent illegal immigration after Brexit?

Are there any other methods to apply to solving simultaneous equations?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

Am I thawing this London Broil safely?

STM32 programming and BOOT0 pin

Time travel alters history but people keep saying nothing's changed

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Did 3000BC Egyptians use meteoric iron weapons?

Why isn't airport relocation done gradually?

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

What does "fetching by region is not available for SAM files" means?



Remotely access postgresql database



The 2019 Stack Overflow Developer Survey Results Are Inhow to create a postgres on NFS?How do I install pgAdmin III for postgreSQL 9.2?Cannot open portInteracting with PostgreSQL on remote server through SSH tunnel?postgresql broken after 14.04 despite succesful pg_upgradeCannot connect to Port 5432Stopping a postgresql instanceRunning two PostgreSQL servers in same Ubuntu machineHow do I solve a “server version mismatch” with pg_dump when I need BOTH PostgreSQL servers installed?could not connect to server: No such file or directory in PostgreSQLCan't access PostgreSQL after crash restart, reports dbus error



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








43















I need to access a postgresql database from a remote machine on a VPS at DigitalOcean running 12.10 and postgresql 9.1.



How do I do this? I noticed port 5432 is closed, how do I open this?










share|improve this question
























  • Follow steps mentioned in javabypatel.blogspot.in/2015/07/… and change the port number present in postgresql.conf file. after changing port restart PostgreSQL server.

    – Jayesh
    Aug 11 '15 at 3:49

















43















I need to access a postgresql database from a remote machine on a VPS at DigitalOcean running 12.10 and postgresql 9.1.



How do I do this? I noticed port 5432 is closed, how do I open this?










share|improve this question
























  • Follow steps mentioned in javabypatel.blogspot.in/2015/07/… and change the port number present in postgresql.conf file. after changing port restart PostgreSQL server.

    – Jayesh
    Aug 11 '15 at 3:49













43












43








43


16






I need to access a postgresql database from a remote machine on a VPS at DigitalOcean running 12.10 and postgresql 9.1.



How do I do this? I noticed port 5432 is closed, how do I open this?










share|improve this question
















I need to access a postgresql database from a remote machine on a VPS at DigitalOcean running 12.10 and postgresql 9.1.



How do I do this? I noticed port 5432 is closed, how do I open this?







remote-access postgresql vps






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 19 '14 at 16:06









Braiam

52.6k20138223




52.6k20138223










asked Feb 19 '14 at 14:14









Øyvind Øyvind

318136




318136












  • Follow steps mentioned in javabypatel.blogspot.in/2015/07/… and change the port number present in postgresql.conf file. after changing port restart PostgreSQL server.

    – Jayesh
    Aug 11 '15 at 3:49

















  • Follow steps mentioned in javabypatel.blogspot.in/2015/07/… and change the port number present in postgresql.conf file. after changing port restart PostgreSQL server.

    – Jayesh
    Aug 11 '15 at 3:49
















Follow steps mentioned in javabypatel.blogspot.in/2015/07/… and change the port number present in postgresql.conf file. after changing port restart PostgreSQL server.

– Jayesh
Aug 11 '15 at 3:49





Follow steps mentioned in javabypatel.blogspot.in/2015/07/… and change the port number present in postgresql.conf file. after changing port restart PostgreSQL server.

– Jayesh
Aug 11 '15 at 3:49










4 Answers
4






active

oldest

votes


















70














To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change



listen_addresses='localhost'


to



listen_addresses='*'


and restart your DBMS



invoke-rc.d postgresql restart


now you can connect with



$ psql -h hostname -U username -d database


if you are unable to authentify yourself, then you need to give your user access rights to your database



Edit your



/etc/postgresql/9.1/main/pg_hba.conf


and add



host all all all md5


(This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).



Hereafter you need also a reload



invoke-rc.d postgresql reload


I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.






share|improve this answer




















  • 4





    In particular, you should enable SSL.

    – Craig Ringer
    Feb 19 '14 at 14:38











  • Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

    – Øyvind
    Feb 19 '14 at 14:46






  • 2





    is the server listening? check with netstat -nlt|grep :5432

    – user224465
    Feb 19 '14 at 14:50






  • 1





    I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

    – gc5
    Feb 25 '15 at 15:58











  • For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

    – Heather92065
    Nov 7 '16 at 19:00


















24














This does not work anymore, if it ever did :




host all all * md5




The correct possible lines for this are :




host all all 0.0.0.0/0 md5 #ipv4 range



host all all ::0/0 md5 #ipv6 range



host all all all md5 #all ip




Source






share|improve this answer


















  • 3





    This definitely did the trick. The above answer definitely did not work.

    – Mike
    Aug 6 '17 at 18:43











  • Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

    – Peter Krauss
    May 7 '18 at 22:48











  • @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

    – Mike
    May 14 '18 at 21:57


















1














For the message "server not listening", that happen to me was, that i don't erase of # on the archive postgresql.conf
i mean:




#listen_addresses='localhost'




to:




listen_addresses='*'




(Sorry for my english).






share|improve this answer






























    0















    The highest-voted and accepted answer has serious security-impolications. This method is disabled by default for good reasons.




    Better use local port forwarding with ssh:



    ssh -L local_port:localhost:foreign_port user@server



    Start the port forwarding:



    ssh -L 5432:localhost:5432 user@your-server.com
    #or
    ssh -L 5432:127.0.0.1:5432 user@your-server.com


    (Change local and foreign ports to fit your configuration).



    Then you can directly connect to the database from your local computer:



    psql -U db_user -p local_port -l





    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f423165%2fremotely-access-postgresql-database%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      70














      To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change



      listen_addresses='localhost'


      to



      listen_addresses='*'


      and restart your DBMS



      invoke-rc.d postgresql restart


      now you can connect with



      $ psql -h hostname -U username -d database


      if you are unable to authentify yourself, then you need to give your user access rights to your database



      Edit your



      /etc/postgresql/9.1/main/pg_hba.conf


      and add



      host all all all md5


      (This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).



      Hereafter you need also a reload



      invoke-rc.d postgresql reload


      I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.






      share|improve this answer




















      • 4





        In particular, you should enable SSL.

        – Craig Ringer
        Feb 19 '14 at 14:38











      • Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

        – Øyvind
        Feb 19 '14 at 14:46






      • 2





        is the server listening? check with netstat -nlt|grep :5432

        – user224465
        Feb 19 '14 at 14:50






      • 1





        I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

        – gc5
        Feb 25 '15 at 15:58











      • For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

        – Heather92065
        Nov 7 '16 at 19:00















      70














      To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change



      listen_addresses='localhost'


      to



      listen_addresses='*'


      and restart your DBMS



      invoke-rc.d postgresql restart


      now you can connect with



      $ psql -h hostname -U username -d database


      if you are unable to authentify yourself, then you need to give your user access rights to your database



      Edit your



      /etc/postgresql/9.1/main/pg_hba.conf


      and add



      host all all all md5


      (This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).



      Hereafter you need also a reload



      invoke-rc.d postgresql reload


      I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.






      share|improve this answer




















      • 4





        In particular, you should enable SSL.

        – Craig Ringer
        Feb 19 '14 at 14:38











      • Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

        – Øyvind
        Feb 19 '14 at 14:46






      • 2





        is the server listening? check with netstat -nlt|grep :5432

        – user224465
        Feb 19 '14 at 14:50






      • 1





        I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

        – gc5
        Feb 25 '15 at 15:58











      • For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

        – Heather92065
        Nov 7 '16 at 19:00













      70












      70








      70







      To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change



      listen_addresses='localhost'


      to



      listen_addresses='*'


      and restart your DBMS



      invoke-rc.d postgresql restart


      now you can connect with



      $ psql -h hostname -U username -d database


      if you are unable to authentify yourself, then you need to give your user access rights to your database



      Edit your



      /etc/postgresql/9.1/main/pg_hba.conf


      and add



      host all all all md5


      (This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).



      Hereafter you need also a reload



      invoke-rc.d postgresql reload


      I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.






      share|improve this answer















      To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change



      listen_addresses='localhost'


      to



      listen_addresses='*'


      and restart your DBMS



      invoke-rc.d postgresql restart


      now you can connect with



      $ psql -h hostname -U username -d database


      if you are unable to authentify yourself, then you need to give your user access rights to your database



      Edit your



      /etc/postgresql/9.1/main/pg_hba.conf


      and add



      host all all all md5


      (This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).



      Hereafter you need also a reload



      invoke-rc.d postgresql reload


      I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited May 7 '18 at 23:48









      Daniel Vérité

      55828




      55828










      answered Feb 19 '14 at 14:37







      user224465














      • 4





        In particular, you should enable SSL.

        – Craig Ringer
        Feb 19 '14 at 14:38











      • Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

        – Øyvind
        Feb 19 '14 at 14:46






      • 2





        is the server listening? check with netstat -nlt|grep :5432

        – user224465
        Feb 19 '14 at 14:50






      • 1





        I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

        – gc5
        Feb 25 '15 at 15:58











      • For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

        – Heather92065
        Nov 7 '16 at 19:00












      • 4





        In particular, you should enable SSL.

        – Craig Ringer
        Feb 19 '14 at 14:38











      • Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

        – Øyvind
        Feb 19 '14 at 14:46






      • 2





        is the server listening? check with netstat -nlt|grep :5432

        – user224465
        Feb 19 '14 at 14:50






      • 1





        I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

        – gc5
        Feb 25 '15 at 15:58











      • For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

        – Heather92065
        Nov 7 '16 at 19:00







      4




      4





      In particular, you should enable SSL.

      – Craig Ringer
      Feb 19 '14 at 14:38





      In particular, you should enable SSL.

      – Craig Ringer
      Feb 19 '14 at 14:38













      Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

      – Øyvind
      Feb 19 '14 at 14:46





      Okey, I tried this, but when I try to connect using pgAdmin from my computer, I get "Server not listening". I added to iptables, and when I run iptables -L the following shows: ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql When checking the IP and PORT on this site (yougetsignal.com/tools/open-ports), it says the port is closed

      – Øyvind
      Feb 19 '14 at 14:46




      2




      2





      is the server listening? check with netstat -nlt|grep :5432

      – user224465
      Feb 19 '14 at 14:50





      is the server listening? check with netstat -nlt|grep :5432

      – user224465
      Feb 19 '14 at 14:50




      1




      1





      I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

      – gc5
      Feb 25 '15 at 15:58





      I would insert the host row in a more strict way: host <database> <user> <remote_client_IPaddress>/24 md5

      – gc5
      Feb 25 '15 at 15:58













      For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

      – Heather92065
      Nov 7 '16 at 19:00





      For Postgresql version 9.5 you may need to restart the server before the listen_addresses will take effect.

      – Heather92065
      Nov 7 '16 at 19:00













      24














      This does not work anymore, if it ever did :




      host all all * md5




      The correct possible lines for this are :




      host all all 0.0.0.0/0 md5 #ipv4 range



      host all all ::0/0 md5 #ipv6 range



      host all all all md5 #all ip




      Source






      share|improve this answer


















      • 3





        This definitely did the trick. The above answer definitely did not work.

        – Mike
        Aug 6 '17 at 18:43











      • Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

        – Peter Krauss
        May 7 '18 at 22:48











      • @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

        – Mike
        May 14 '18 at 21:57















      24














      This does not work anymore, if it ever did :




      host all all * md5




      The correct possible lines for this are :




      host all all 0.0.0.0/0 md5 #ipv4 range



      host all all ::0/0 md5 #ipv6 range



      host all all all md5 #all ip




      Source






      share|improve this answer


















      • 3





        This definitely did the trick. The above answer definitely did not work.

        – Mike
        Aug 6 '17 at 18:43











      • Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

        – Peter Krauss
        May 7 '18 at 22:48











      • @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

        – Mike
        May 14 '18 at 21:57













      24












      24








      24







      This does not work anymore, if it ever did :




      host all all * md5




      The correct possible lines for this are :




      host all all 0.0.0.0/0 md5 #ipv4 range



      host all all ::0/0 md5 #ipv6 range



      host all all all md5 #all ip




      Source






      share|improve this answer













      This does not work anymore, if it ever did :




      host all all * md5




      The correct possible lines for this are :




      host all all 0.0.0.0/0 md5 #ipv4 range



      host all all ::0/0 md5 #ipv6 range



      host all all all md5 #all ip




      Source







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Sep 20 '16 at 10:34









      KethrywerynKethryweryn

      34123




      34123







      • 3





        This definitely did the trick. The above answer definitely did not work.

        – Mike
        Aug 6 '17 at 18:43











      • Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

        – Peter Krauss
        May 7 '18 at 22:48











      • @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

        – Mike
        May 14 '18 at 21:57












      • 3





        This definitely did the trick. The above answer definitely did not work.

        – Mike
        Aug 6 '17 at 18:43











      • Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

        – Peter Krauss
        May 7 '18 at 22:48











      • @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

        – Mike
        May 14 '18 at 21:57







      3




      3





      This definitely did the trick. The above answer definitely did not work.

      – Mike
      Aug 6 '17 at 18:43





      This definitely did the trick. The above answer definitely did not work.

      – Mike
      Aug 6 '17 at 18:43













      Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

      – Peter Krauss
      May 7 '18 at 22:48





      Please @Mike express what is correct: host all all all md5 will work fine? It is correct? any security problem?

      – Peter Krauss
      May 7 '18 at 22:48













      @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

      – Mike
      May 14 '18 at 21:57





      @peterkrauss Yes, host all all all md5 worked for me. Security problem? Of course it is, but for what I was doing it was just fine. (Internal network)

      – Mike
      May 14 '18 at 21:57











      1














      For the message "server not listening", that happen to me was, that i don't erase of # on the archive postgresql.conf
      i mean:




      #listen_addresses='localhost'




      to:




      listen_addresses='*'




      (Sorry for my english).






      share|improve this answer



























        1














        For the message "server not listening", that happen to me was, that i don't erase of # on the archive postgresql.conf
        i mean:




        #listen_addresses='localhost'




        to:




        listen_addresses='*'




        (Sorry for my english).






        share|improve this answer

























          1












          1








          1







          For the message "server not listening", that happen to me was, that i don't erase of # on the archive postgresql.conf
          i mean:




          #listen_addresses='localhost'




          to:




          listen_addresses='*'




          (Sorry for my english).






          share|improve this answer













          For the message "server not listening", that happen to me was, that i don't erase of # on the archive postgresql.conf
          i mean:




          #listen_addresses='localhost'




          to:




          listen_addresses='*'




          (Sorry for my english).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 24 '15 at 19:23









          mrlinuxmrlinux

          111




          111





















              0















              The highest-voted and accepted answer has serious security-impolications. This method is disabled by default for good reasons.




              Better use local port forwarding with ssh:



              ssh -L local_port:localhost:foreign_port user@server



              Start the port forwarding:



              ssh -L 5432:localhost:5432 user@your-server.com
              #or
              ssh -L 5432:127.0.0.1:5432 user@your-server.com


              (Change local and foreign ports to fit your configuration).



              Then you can directly connect to the database from your local computer:



              psql -U db_user -p local_port -l





              share|improve this answer



























                0















                The highest-voted and accepted answer has serious security-impolications. This method is disabled by default for good reasons.




                Better use local port forwarding with ssh:



                ssh -L local_port:localhost:foreign_port user@server



                Start the port forwarding:



                ssh -L 5432:localhost:5432 user@your-server.com
                #or
                ssh -L 5432:127.0.0.1:5432 user@your-server.com


                (Change local and foreign ports to fit your configuration).



                Then you can directly connect to the database from your local computer:



                psql -U db_user -p local_port -l





                share|improve this answer

























                  0












                  0








                  0








                  The highest-voted and accepted answer has serious security-impolications. This method is disabled by default for good reasons.




                  Better use local port forwarding with ssh:



                  ssh -L local_port:localhost:foreign_port user@server



                  Start the port forwarding:



                  ssh -L 5432:localhost:5432 user@your-server.com
                  #or
                  ssh -L 5432:127.0.0.1:5432 user@your-server.com


                  (Change local and foreign ports to fit your configuration).



                  Then you can directly connect to the database from your local computer:



                  psql -U db_user -p local_port -l





                  share|improve this answer














                  The highest-voted and accepted answer has serious security-impolications. This method is disabled by default for good reasons.




                  Better use local port forwarding with ssh:



                  ssh -L local_port:localhost:foreign_port user@server



                  Start the port forwarding:



                  ssh -L 5432:localhost:5432 user@your-server.com
                  #or
                  ssh -L 5432:127.0.0.1:5432 user@your-server.com


                  (Change local and foreign ports to fit your configuration).



                  Then you can directly connect to the database from your local computer:



                  psql -U db_user -p local_port -l






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 days ago









                  RoVoRoVo

                  8,1901943




                  8,1901943



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f423165%2fremotely-access-postgresql-database%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

                      How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

                      Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü