Skip site navigation (1) Skip section navigation (2)

Re: Cannot connect to remote postgres using php

From: "Dimitris Sakellarios" <dimitris(dot)sakellarios(at)telesuite(dot)gr>
To: <archanakknn(at)gmail(dot)com>,<pgsql-php(at)postgresql(dot)org>
Subject: Re: Cannot connect to remote postgres using php
Date: 2012-04-30 16:40:36
Message-ID: C9E90317C38C42179737E941E16F7685@toshiba (view raw or flat)
Thread:
Lists: pgsql-php
First of all set all firewall down and then test again.

 

I remember you said that the PHP server and the PGSQL server are on
different machines? Is that correct?

 

If so how did you succeed to connect to local host? Did you move your PHP
code to the same machine hosting your PGSQL server or do you host a PGSQL
server on both machines?

 

Provide some more details (a small design) to give more help else it is
hopeless like that sorry. Also provide the the part of the PHP you try to
create the connection.

 

Try the below proposal.

 

On server that host the PHP (IP=y.y.y.y)

 

<?php

..

pg_connect("host=x.x.x.x port=5432 dbname=AAAAAAA user=BBBBBBBB
password=BBBBBBBB") or die('Could not connect: ' . pg_last_error());

..

?>

 

On server that host PGSQL (IP=x.x.x.x)

 

Inside pg_hba.conf

 

.

hostnossl    all         all         0.0.0.0/0          trust

..

 

Inside postgresql.conf

 

listen_addresses = 'x.x.x.x,localhost'

port = 5432

 

Test and report.

 

BR,

 

 

Sakellarios Dimitris

Telesuite ltd Telecommunication and Internet Services

Address : T. Sofouli 14, Post Code 16344, Ilioupoli - Athens, Greece

T.: +30 211 760 1300 F.: +30 211 176 9999 M.: +30 6982 550 850 e-mail:
dimitris.sakellarios <mailto:dimitris(dot)sakellarios(at)telesuite(dot)gr>
@telesuite.gr  url: http://www.telesuite.gr <http://www.telesuite.gr/> 

  _____  

From: pgsql-php-owner(at)postgresql(dot)org [mailto:pgsql-php-owner(at)postgresql(dot)org]
On Behalf Of Archana K N
Sent: Monday, April 30, 2012 6:58 PM
To: pgsql-php(at)postgresql(dot)org
Subject: Re: [PHP] Cannot connect to remote postgres using php

 

My postgres server is listening to same port . I tried changing both but
same error is showing. 

 

I restarted the servers after changing the conf files. pgadmin3 is running
on both servers and i can connect them remotely. I am able to connect to
local host using the php code.

 

I think i have changed the files correctly , some antivirus softwares are
running in the system i dont know whether that causes the problem.



 

-- 
-------------------
regards
archana
--------------------

Responses

pgsql-php by date

Next:From: Archana K NDate: 2012-04-30 18:10:33
Subject: Re: Cannot connect to remote postgres using php
Previous:From: sven@is-buchholz.comDate: 2012-04-30 16:19:48
Subject: Re: Cannot connect to remote postgres using php

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group