[mapserver-users] Remote PostGIS server connection problem

Jeff McKenna jmckenna at gatewaygeomatics.com
Thu Aug 23 06:21:49 PDT 2012


On 12-08-23 10:02 AM, Matej Mailing wrote:
> Hi,
> 
> I am running 6.0.1 on a FreeBSD host. Everything works perfect when I
> connect to the local PostGIS server (located on the same machine as
> the Mapserver is running on). When I try to connect to the PostGIS
> server that is not in the same network, I get the following error:
> "msDrawMap(): Image handling error. Failed to draw layer named
> 'LAYER_NAME'. msPostGISLayerOpen(): Query error. Database connection
> failed (could not connect to server: Permission denied Is the server
> running on host "IP" and accepting TCP/IP connections on port 5432? Is
> it allowing connections? Does the specified user exist? Is the
> password valid? Is the database on the standard port?
> 
> 1. I can connect to the server IP on port 5432 via paql from console
> from the machine where Mapserver is running.
> 2. When doing tcpdump dst 5432 on the PostGIS server that is outside,
> I see no traffic comming in so basically when the error is displayed
> it is not due to remote server settings.
> 
> I was browsing on the web and found out that people that were using
> SELinux had to enable the option httpd_can_network_connect. It seems
> like the Apache is not allowed to initiate a remote connection to a
> non-local IP address. Is it the Apache limitation? Is it the OS
> limitation or is it the Mapserver limitation (I am pretty sure that it
> isn't, but I don't know where to look anymore ...)
> 
> After pulling my hair for several hours any help or idea would be very
> welcome :-)
> 

You can test without Apache by using the MapServer commandline utility
shp2img (http://mapserver.org/utilities/shp2img.html).  Use the
"-all_debug 5" switch to see more info.

(that's my favorite debugging tool)

Next I would check the settings in the remote Postgres data folder's
"pg_hba.conf" file.

-jeff




-- 
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




More information about the mapserver-users mailing list