3

I installed PostgreSQL version 8.3.19 on windows server 2003. After configuration, I can access locally (from a php script) but not remotely (from another similar php script, from another machine).
1) NAT is configured and tested for the port 5432
2) Firewall authorises the application
3) I set the pg_hba.conf file:

host all all 0.0.0.0/0 md5  

4) I set the postgresql.conf:

listen_addresses='*'  

5) I created a role with pgAdminIII for the access from an application. I declared him superuser (just for the tests) and named him TOTO
6) My local script is:

$con=pg_connect("host=localhost port=5432 user=TOTO password=PW dbname=test")  

7) My remote script is:

$con=pg_connect("host=myhostname port=5432 user=TOTO password=PW dbname=test")  

I don't see what I could forget. Could you light me ?

10
  • I don't know ;-( I tried pg_last_error but returns blank. As the reply is long, I suppose to have a timeout. Commented Jul 31, 2012 at 16:34
  • did you try connecting to the postgres remotely by command line? Commented Jul 31, 2012 at 16:36
  • Give me the prodedure. I tried telnet myhostname 5432. The reply is time out Commented Jul 31, 2012 at 16:38
  • 2
    psql -U TOTO -h myhostname -p 5432 -W if you are getting timeout, NAT, F/W, DNS or routing is not configured properly I guess Commented Jul 31, 2012 at 16:44
  • This is the case ! May we continue or is it another subject ? Commented Jul 31, 2012 at 17:05

1 Answer 1

2

If you are getting timeouts then as mask8 says it's probably firewall configuration problems. See if you can connect to your target IP from the server itself. Also enable connection logging in postgresql's config.

Oh, and unless you really have to use that version, install 9.1, 8.3 is due for retirement fairly soon.

Sign up to request clarification or add additional context in comments.

9 Comments

I suppose by psql -U TOTO -h localhost -p 5432 -W -d test ? if yes then I can
Download from EnterpriseDB ? pgInstaller 9.1.x doesn't exist on postgresql.org !
Sure, EnterpriseDB do the windows packaging. Don't use "-h localhost" in your test, use "-h 123.123.123.123" or whatever the external IP address is.
with -h 192.168.1.1 I can connect, with -h 82.x.x.x I cannot. I tested on the server itself and from another machine on the lan.
Assuming the setting listed above, that suggests 82.x is firewalled somehow. You can check what ports PostgreSQL has open if there is any doubt: petri.co.il/quickly_find_local_open_ports.htm
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.