I have MapServer 6.04 running in CentOS 6.7. I am able to serve shapefiles and GeoJSON, but when I try to connect to a PostGIS (2.1.8) enabled PostgreSQL (9.4.5) database it fails with the error: Database connection failed. I can connect to the database via QGIS and python from other machines. I can also run ogrinfo PG:"user=radar dbname=radar" ktlx -summary and get the following output:

Layer name: ktlx  
Geometry: 3D Multi Polygon  
Feature Count: 6  
Extent: (-98.807300, 32.737200) - (-93.488900, 36.542300)  
Layer SRS WKT:  
    SPHEROID["GRS 1980",6378137,298.257222101,  
FID Column = index  
Geometry Column = geom  
radar: String (0.0)  
val: Integer (3.0)  

The connection info in my .map file is:

CONNECTION "host= dbname=radar user=radar"

Every reference I have found in the documentation indicates that the the CONNECTIONTYPE and CONNECTION strings I am using are correct. Is there a different connection string to use?

  • 4
    pg_hba.conf needs to accept connections even localhost see stackoverflow.com/questions/3278379/… – Mapperz Nov 6 '15 at 1:41
  • 1
    If the question title was "PostgreSQL is refusing connections from MapServer" you'd be a whole lot closer to solving the problem. – Vince Nov 6 '15 at 2:10
  • have you tried it with "localhost" instead of ""? I also would try to set a password and use it. – Master Bee Nov 6 '15 at 6:50
  • The pg_hba.conf file is set to receive connection from localhost as well as 127.0.01. I tried localhost, with and without a password, with md5 and trust. None of them work, but they all work with ogrinfo command. – Bill Nov 7 '15 at 3:58

As one last check I set selinux to Permissive and was able to connect. This is not how I want to leave it, so now to the selinux logs to get the proper context for apache and map server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.