opengisch / QFieldCloud

QFieldCloud allows seamless synchronization of your field data with your spatial infrastructure with change tracking, team management and online-offline work capabilities in QField.
https://qfield.cloud
MIT License
107 stars 50 forks source link

PostGIS layer and user name in pg_service secret #406

Open janekska opened 2 years ago

janekska commented 2 years ago

I have a project with PostGIS layer (db pg_hba.conf configured for a given user and database) and pg_service secret file where I set db host, db name, user name (not root of course) and passw.

Upon sync to qField I am getting connection error (found on qField cloud job details): FATAL: no pg_hba.conf entry for host "185.203.114.168", user "root", database "mydb_test", SSL off WARNING:QGIS_MSGLOG:1 unavailable layer(s) found:

I tried to double check & rewrite pg_service secret, but getting the same - "... user "root", ..."

So - what could be wrong?

brgds

suricactus commented 2 years ago

You need to configure your PostgreSQL server to allow connections from 185.203.114.168, which is the IP of app.qfield.cloud.

There are plenty of answers online how to do this, but this one is well structured (the issue is solved in the comments of the question itself).

janekska commented 2 years ago

I have configured for pg_hba.conf already:

host mydbname quser 185.203.114.168/32 md5

And this is my secret pg_service config:

[sg_db_test] dbname=mydbname user=quser password=hidden host=my.host.ip.addr sslmode=prefer

The problem is a bit different. Or the question: Why job log on qField cloud tells that it is connecting to myPostGIS database as root, if in my secret it is configured as another user (as quser)? I did have to solve similar problems before, but error messages tells what user is used to make a connection.

suricactus commented 2 years ago

There might be something that is configured to use the root user in the QGIS project itself? Can you grep the .qgs file contents for root and see if you find something suspicious? Sharing your username+project combo will allow me to have a look too.

janekska commented 2 years ago

I am avoiding using root user at all - bad habit. Didn't find in qgs file anything regarding "root" user.

Will the link to my project will be enough? Let me know if I can help somehow else (more info or some test).