[mapserver-users] Remote PostGIS server connection problem
Matej Mailing
mailing at tam.si
Thu Aug 23 12:30:03 PDT 2012
Hi,
when I use
shp2img -m mapfile.map -all_debug 5 from the server with the same map
file that causes mentioned error in Mapserver, I can see in the log
that the server connects successfully so it works as it should with
shp2img - thanks for this tip, I will use it in the future to debug
connection string issues with map files.
However, it still doesn't work from Apache and Mapserver.
With Mapserver the connection doesn't even come to the remote Postgres
since I see nothing in tcpdump, but everything is OK in pg_hba.conf
because I can connect from the server where Mapserver is running to
the remote server with pgsql from console.
Best regards,
Matej
2012/8/23 Jeff McKenna <jmckenna at gatewaygeomatics.com>:
> 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/
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list