Permission denied for relation gorp_migrations

Hi,

I’ve just installed the lora server, but I’m unable to start the lora-app-server.

INFO[0000] starting LoRa App Server                      docs="https://www.loraserver.io/" version=1.0.2
INFO[0000] connecting to postgresql
INFO[0000] setup redis connection pool
INFO[0000] handler/mqtt: TLS config is empty
INFO[0000] handler/mqtt: connecting to mqtt broker       server="tcp://localhost:1883"
INFO[0000] applying database migrations
INFO[0000] handler/mqtt: connected to mqtt broker
INFO[0000] handler/mqtt: subscribing to tx topic         qos=0 topic=application/+/device/+/tx
FATA[0000] applying migrations error: pq: **permission denied for relation gorp_migrations**

I do have automigrate=true on both (If I disable automigrate it works.)
and jwt_secret set

EDIT: if I disable automigrate I’m able to open the web interface but the response to admin/admin login is: Error pq: relation “user” does not exist (code: 2)

any advice on how to proceed?

thanks,
Tiago

How did you create your DBs? It seems to me that your lora-app-server’s DB user is able to connect to your DB but doesn’t have full privileges on it, apparently including insert, and thus can’t write to the gorp_migrations table. I’d suggest you drop your databases and recreate them:

sudo -u postgres psql
drop database your-lora-app-server-db;
drop database your-loraserver-db;
create database your-lora-app-server-db with owner your-lora-app-server-user;
create database your-loraserver-db with owner your-loraserver-user;

\c lora-app-server-db --Connect to lora-app-server DB to create the pg_trgm extension.

create extension pg_trgm;

\q
2 Likes

@iegomez
Thanks. I did exactly like you posted (from the intructions) but maby did something in the process.

I’ve rebuilt the dbs and now it’s working.

thanks.
tiago

I have the exact same issue, however rebuilding the DBs didn’t help, and I have set them up as described in the first place.

It doesn’t mater how I run it or which permissions I give to the DBs.

Can anyone explain what is this migration and why it’s failing?

Blockquote
$ sudo lora-app-server
INFO[0000] starting LoRa App Server docs=“https://www.loraserver.io/” version=2.0.0
INFO[0000] connecting to postgresql
INFO[0000] setup redis connection pool
INFO[0000] handler/mqtt: TLS config is empty
INFO[0000] handler/mqtt: connecting to mqtt broker server=“tcp://localhost:1883”
INFO[0000] applying database migrations
INFO[0000] handler/mqtt: connected to mqtt broker
INFO[0000] handler/mqtt: subscribing to tx topic qos=0 topic=application/+/device/+/tx
FATA[0000] applying migrations error: pq: permission denied for relation gorp_migrations

Blockquote
$ sudo lora-app-server -c /etc/lora-app-server/lora-app-server.toml
INFO[0000] starting LoRa App Server docs=“https://www.loraserver.io/” version=2.0.0
INFO[0000] connecting to postgresql
INFO[0000] setup redis connection pool
INFO[0000] handler/mqtt: TLS config is empty
INFO[0000] handler/mqtt: connecting to mqtt broker server=“tcp://localhost:1883”
INFO[0000] applying database migrations
INFO[0000] handler/mqtt: connected to mqtt broker
INFO[0000] handler/mqtt: subscribing to tx topic qos=0 topic=application/+/device/+/tx
FATA[0000] applying migrations error: pq: permission denied for relation gorp_migrations