Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgis Plugin: Bad connection #91

Closed
arcadas opened this issue Dec 13, 2014 · 21 comments
Closed

Postgis Plugin: Bad connection #91

arcadas opened this issue Dec 13, 2014 · 21 comments

Comments

@arcadas
Copy link

arcadas commented Dec 13, 2014

Hello,

I would like create a tile server on a EC2 Ubuntu server. I followed this documentation:
http://switch2osm.org/serving-tiles/manually-building-a-tile-server-14-04/

After I successfully import data into the database from pbf file, I execute this command:

sudo -u <username> renderd -f -c /usr/local/etc/renderd.conf

But I got the next error message:

renderd[12282]: An error occurred while loading the map layer 'default': Postgis Plugin: Bad connection
Connection string: ' dbname=gis connect_timeout=4'
  encountered during parsing of layer 'landuse_gen0' in Layer at line 193 of '/usr/local/share/maps/style/OSMBright/OSMBright.xml'

I check all config file, but I can not find any mistake. And I can connect to "gis" db with this user:

psql -d gis -U <username> -W

Have you any idea, what is the problem?

Thanks in advance!

@pnorman
Copy link
Contributor

pnorman commented Dec 13, 2014

I check all config file, but I can not find any mistake. And I can connect to "gis" db with this user:

psql -d gis -U <username> -W

What happens if you try connecting as the user you renderd is running as?

@arcadas
Copy link
Author

arcadas commented Dec 14, 2014

I can connect with that user (mapnik).

# This return with bad connection
sudo -u mapnik renderd -f -c /usr/local/etc/renderd.conf
# This works
psql -d gis -U mapnik -W

@pnorman
Copy link
Contributor

pnorman commented Dec 14, 2014

I note you're forcing a prompt for a password with -W, what happens if you don't?

@arcadas
Copy link
Author

arcadas commented Dec 15, 2014

Works similarly:

ubuntu@/usr/local/share/maps/style/OSMBright$ psql -d gis -U mapnik
Password for user mapnik: 
psql (9.3.5)
Type "help" for help.
gis=> \q
ubuntu@/usr/local/share/maps/style/OSMBright$ psql -d gis -U mapnik -W
Password for user mapnik: 
psql (9.3.5)
Type "help" for help.
gis=> \q

@arcadas
Copy link
Author

arcadas commented Dec 15, 2014

When I set PostgreSQL login method to "trust" at /etc/postgresql/9.3/main/pg_hba.conf file, it started to work without error...

@pnorman
Copy link
Contributor

pnorman commented Dec 15, 2014

Works similarly:

ubuntu@/usr/local/share/maps/style/OSMBright$ psql -d gis -U mapnik
Password for user mapnik: 

This is an example of it not working without manual intervention - you need to set PGPASS or set the password some other way, or change authentication so that you are not requiring a password.

@arcadas
Copy link
Author

arcadas commented Dec 15, 2014

Thanks!

@arcadas arcadas closed this as completed Dec 15, 2014
@menkaff
Copy link

menkaff commented Feb 14, 2015

I get the same error but i change login method to trust but it is still geeting that error and when i stop PostgreSQL nothing changes , i mean that the error is a bad connection even the PostgreSQL server is down. Have you any idea? Thanks

@pnorman
Copy link
Contributor

pnorman commented Feb 15, 2015

Probably the same issue - how you're trying to connect with PostgreSQL doesn't match what the server is allowing.

@menkaff
Copy link

menkaff commented Feb 16, 2015

i correct that issue but still 404 error and no tiles in tile folder and no error in syslog
syslog:
///
renderd[28926]: Rendering daemon started
renderd[28926]: Initiating reqyest_queue
renderd[28926]: Parsing section renderd
renderd[28926]: Parsing render section 0
renderd[28926]: Parsing section mapnik
renderd[28926]: Parsing section default
renderd[28926]: config renderd: unix socketname=/var/run/renderd/renderd.sock
renderd[28926]: config renderd: num_threads=4
renderd[28926]: config renderd: num_slaves=0
renderd[28926]: config renderd: tile_dir=/var/lib/mod_tile
renderd[28926]: config renderd: stats_file=/var/run/renderd/renderd.stats
renderd[28926]: config mapnik: plugins_dir=/usr/local/lib/mapnik/input
renderd[28926]: config mapnik: font_dir=/usr/share/fonts/truetype/ttf-dejavu
renderd[28926]: config mapnik: font_dir_recurse=1
renderd[28926]: config renderd(0): Active
renderd[28926]: config renderd(0): unix socketname=/var/run/renderd/renderd.sock
renderd[28926]: config renderd(0): num_threads=4
renderd[28926]: config renderd(0): tile_dir=/var/lib/mod_tile
renderd[28926]: config renderd(0): stats_file=/var/run/renderd/renderd.stats
renderd[28926]: config map 0: name(default) file(/usr/share/mapnik-osm-carto-data/openstreetmap-carto-master/osmdef.xml) uri(/osm_tiles/) htcp() host(localhost)
renderd[28926]: Initialising unix server socket on /var/run/renderd/renderd.sock
renderd[28926]: Created server socket 4
renderd[28926]: Renderd is using mapnik version 2.2.0
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerifCondensed-BoldItalic.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-BoldOblique.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Italic.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed-Oblique.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerifCondensed-Bold.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Oblique.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-BoldOblique.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerifCondensed.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-ExtraLight.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerifCondensed-Italic.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed-BoldOblique.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-BoldItalic.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed-Bold.ttf
renderd[28926]: DEBUG: Loading font: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf
renderd[28927]: Starting stats thread
renderd[28927]: Loading parameterization function for
renderd[28927]: message repeated 3 times: [ Loading parameterization function for ]
renderd[28927]: Using web mercator projection settings

plz help it is becoming a nightmare for me. thanks in advance

@arcadas
Copy link
Author

arcadas commented Feb 16, 2015

Did you try this request?
http://yourserveraddress/osm_tiles/0/0/0.png
What happen if you try this?
http://yourserveraddress/0/0/0.png
OR
http://yourserveraddress

@menkaff
Copy link

menkaff commented Feb 16, 2015

it works finally ... when i reload apache no error terminal , but in apache log i see uri "/osm/" not "/osm_tiles/"
apache log:
///
[tile:notice] [pid 1931] Loading tile config default at /osm/ for zooms 0 - 20 from tile directory /var/lib/mod_tile with extension .png and mime type image/png
///
i have no idea where is that "/osm/" come from so i change the "/osm_tiles/" to "/osm/" in renderd.conf and tile server works :)
Thank you both so much

@heyaibek
Copy link

I changed method in file pg_hda.conf to trust, made renderd.conf file correctly.
What can more happens?

Thanks!

PROBLEM: An error occurred while loading the map layer 'default': Postgis Plugin: Bad connection
Connection string: ' dbname=osm connect_timeout=4'
encountered during parsing of layer 'landuse_gen0' in Layer at line 193 of '/usr/local/share/maps/style/OSMBright/OSMBright.xml'

@menkaff
Copy link

menkaff commented Jun 22, 2015

would you plz test that with another style , i recommend openstreetmap-carto , i had problems with osmbright.

@avirupd-egnaroinc
Copy link

I am trying to access remote systems postgis. I have configured the datasource-settings.xml like below

postgis

192.168.1.3
5432

gis

false

-20037508,-19929239,20037508,19929239

but while rendering renderd -f -c /usr/local/etc/renderd.conf I am getting the following error-
An error occurred while loading the map layer 'default': Postgis Plugin: Bad connection
Connection string: ' dbname=gis connect_timeout=4'
encountered during parsing of layer 'landuse_gen0' in Layer at line 192 of '/usr/local/share/maps/style/OSMBright/OSMBright.xml'

I also have changed the pg_hba.conf to trust for the client ip. But nothing works.

Please help me with this. thanks in advance

@woodpeck
Copy link
Contributor

This issue tracker is for tracking bugs in the software, not for asking questions about how to run it! An appropriate place to discuss would be this mailing list: https://lists.openstreetmap.org/listinfo/tile-serving.

Having said that, make sure you have actually created a PostgreSQL user (createuser) with the same name as given in datasource-settings.xml or, if no user name is given there, the unix user name under which renderd runs. Also make sure you're setting "trust" also for the non-IP access line in pg_hba.conf.

@menkaff
Copy link

menkaff commented Mar 18, 2016

@avirupd-egnaroinc this may happen because of two reason first setting trust in pg_hba.conf and permissions, check them.
@woodpeck i agree with u :)

@ephilosophy
Copy link

I am getting the same error

renderd[12282]: An error occurred while loading the map layer 'default': Postgis Plugin: Bad connection
Connection string: ' dbname=gis connect_timeout=4'
  encountered during parsing of layer 'landuse_gen0' in Layer at line 193 of '/usr/local/share/maps/style/OSMBright/OSMBright.xml'

I have also tried changing pg_hba.conf but nothing worked. Also according to the tutorial I created a user named abhishek but when I try to connect using

psql -d gis -U abhishek -W

I get this error

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I don't know what should I do next. Please help.

@avirupd-egnaroinc
Copy link

@ephilosophy check your postgresql server is running or not.

@alejandrogalera
Copy link

alejandrogalera commented Aug 21, 2020

I am getting the same error

renderd[12282]: An error occurred while loading the map layer 'default': Postgis Plugin: Bad connection
Connection string: ' dbname=gis connect_timeout=4'
  encountered during parsing of layer 'landuse_gen0' in Layer at line 193 of '/usr/local/share/maps/style/OSMBright/OSMBright.xml'

I have also tried changing pg_hba.conf but nothing worked. Also according to the tutorial I created a user named abhishek but when I try to connect using

psql -d gis -U abhishek -W

I get this error

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I don't know what should I do next. Please help.

I got the same error. My postgresql server is running and it's possible to connect it from other host, but not from renderd

@stephankn
Copy link
Contributor

@alejandrogalera this is not a mod_tile issue. The error clearly states that you can not access your database using a socket connection.

The tool psql is part of PostgreSQL. If this already fails connecting, then you have an issue with your setup. Check these settings: https://www.postgresql.org/docs/12/runtime-config-connection.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants