#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0

    Postgre over internet/remote


    Hi,

    I have postgre 9.1 installed on a Windows 7 machine and I'm trying to connect to the database server through the Internet. I have so far done the following configurations:

    postgresql.conf:

    listen_addresses = '*'

    pg_hba.conf:

    # IPv4 local connections:
    host all all 127.0.0.1/32 md5
    host all all 0.0.0.0/0 md5
    # IPv6 local connections:
    host all all ::1/128 md5

    I have restarted the service after the config and made sure the config has been reloaded.

    I have also forwarded port 5432 to the database server machine (on a static ip), disabled the firewall and still it refuses to connect. I can connect locally and from my laptop on the same network. Am I missing anything?

    Kind Regards,
    Carl
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Hi Carl,

    You might have a similar issue than what I have just posted.
    Why you didn't put the IP address of your remote machine in your configuration file?

    Kind Regards.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by Maarvin
    Hi Carl,

    You might have a similar issue than what I have just posted.
    Why you didn't put the IP address of your remote machine in your configuration file?

    Kind Regards.
    Hi,

    I didn't put it in because its not just 1 machine and it could be any IP address (multiple clients etc)

    I just don't understand why its so hard to get this to work, with MySQL its simple, problem is you can't distrubute it with your software which is why im using Postgres...I think I may try firebird SQL

    Carl
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,787
    Rep Power
    349
    Originally Posted by outasync
    I have also forwarded port 5432 to the database server machine (on a static ip), disabled the firewall and still it refuses to connect.
    If you have the entry 0.0.0.0/0 md5 you should be able to connect from anywhere (works for me).
    Are you sure the firewall on the server and the client allow the connection.

    What exactly is the error you get?
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by shammat
    If you have the entry 0.0.0.0/0 md5 you should be able to connect from anywhere (works for me).
    Are you sure the firewall on the server and the client allow the connection.

    What exactly is the error you get?
    When I try to connect using PGadmin i get the following error:

    The server doesn't accept connections: the connection library reports
    could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "##.##.##.##" and accepting TCP/IP connections on port 5432?

    I have completely disabled the firewall on both machines. Now the error is saying it doesn't accept connections then this must mean it is not listening for remote connections yet I have changed the listen_address to '*'. I have trying to short this problem out now for days.

    Carl
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,787
    Rep Power
    349
    Can you ping the server from the machine where pgAdmin is installed?
    Is the server behind a router or something similar?
    Is the client behind a router (possibly blocking ports) or something similar?
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by shammat
    Can you ping the server from the machine where pgAdmin is installed?
    Is the server behind a router or something similar?
    Is the client behind a router (possibly blocking ports) or something similar?
    Hi, thanks for your reply.

    The server is behind a router and port 5432 has been forwarded to it.

    Client is also behind a router and outgoing port 5432 is allowed, also firewall on both have the correct rules in place but for safe measure I have disabled both still with no luck.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,787
    Rep Power
    349
    If a connection is refused by Postgres this is logged in the Postgres logfile (when setting log_connections = true) If you turn that on and see no message, the problem is your network. If you see a message, the problem is in the Postgres configuration.

    Can you ping the server from the client?
    Can you telnet on the Postgres port?
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    I have tried what you suggested and the connection is not reaching the server, so it would seem there is a problem with the port forwarding as I have eliminated both firewall & anti-virus completely. I'll do some more checks but i've never had a problem with port forwarding before
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Hi,

    Did you check if the firewall was open on the database server for incomming client connections?
    What error message did you get?

    Kind Regards.

    Originally Posted by outasync
    Hi,

    I have postgre 9.1 installed on a Windows 7 machine and I'm trying to connect to the database server through the Internet. I have so far done the following configurations:

    postgresql.conf:

    listen_addresses = '*'

    pg_hba.conf:

    # IPv4 local connections:
    host all all 127.0.0.1/32 md5
    host all all 0.0.0.0/0 md5
    # IPv6 local connections:
    host all all ::1/128 md5

    I have restarted the service after the config and made sure the config has been reloaded.

    I have also forwarded port 5432 to the database server machine (on a static ip), disabled the firewall and still it refuses to connect. I can connect locally and from my laptop on the same network. Am I missing anything?

    Kind Regards,
    Carl
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by Maarvin
    Hi,

    Did you check if the firewall was open on the database server for incomming client connections?
    What error message did you get?

    Kind Regards.
    Yes, I also disabled it just to make sure. This is such a strange issue as I only seem to have a problem with postgre.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,787
    Rep Power
    349
    Originally Posted by outasync
    Yes, I also disabled it just to make sure. This is such a strange issue as I only seem to have a problem with postgre.
    Again: can you ping the server from the client?

    Btw: it's either postgres or PostgreSQL, never "postgre".
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    Yes I can ping the server
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Hi,

    Maybe it is a good idea if you post here the error message you get.

    Kind Regards.

IMN logo majestic logo threadwatch logo seochat tools logo