Loomio
Fri 11 Dec 2020

Getting "Internal Server Error" when I try to reach loomio Instance trough domain.

G
Giuseppe Public Seen by 316

Hello everybody. I hope you can help me and I appreciate your time that you are investing in giving guys like me some help.

I tried to move my loomio server to another server - before I was running an own machine in my own home network. Now I would like to use a provided server from a web host.

So what I did is to copy my loomio-deploy folder from the old server (Ubuntu) to the new server (Debian).
I adapted the env-file with a new domain, but same SMTP Server.

The I started the docker-compose. After a while, when I call the domain, I get an "Internal Server Error".


I looked in the logs - what I noticed is a message from the nginx container: ".. upstream is currently not availabe ..". Could this be a reason? What can I do?

loomio-nginx   | nginx.1    | loomio.49grad-mainz.de 95.89.76.82 - - [11/Dec/2020:12:16:52 +0000] "GET /users/sign_in HTTP/2.0" 301 117 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
loomio-nginx   | nginx.1    | 2020/12/11 12:16:52 [error] 107#107: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 95.89.76.82, server: loomio.49grad-mainz.de, request: "GET /dashboard HTTP/2.0", upstream: "http://172.17.0.5:3000/dashboard", host: "loomio.49grad-mainz.de"
loomio-nginx   | nginx.1    | 2020/12/11 12:16:52 [warn] 107#107: *10 upstream server temporarily disabled while connecting to upstream, client: 95.89.76.82, server: loomio.49grad-mainz.de, request: "GET /dashboard HTTP/2.0", upstream: "http://172.17.0.5:3000/dashboard", host: "loomio.49grad-mainz.de"
loomio-app     | source=rack-timeout id=509cbcc7-d6ce-46de-aab5-96730842fb50 timeout=15000ms state=ready
loomio-db      | ERROR:  relation "ahoy_visits" does not exist at character 566
loomio-db      | STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-db      |                             pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-db      |                             c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-db      |                        FROM pg_attribute a
loomio-db      |                        LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-db      |                        LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-db      |                        LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-db      |                       WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-db      |                         AND a.attnum > 0 AND NOT a.attisdropped
loomio-db      |                       ORDER BY a.attnum
loomio-db      |
loomio-app     | method=GET path=/dashboard format=html controller=ApplicationController action=index status=500 error='ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "ahoy_visits" does not exist
loomio-app     | LINE 8:                WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-app     |                                           ^
loomio-app     | :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-app     |                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-app     |                      c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-app     |                 FROM pg_attribute a
loomio-app     |                 LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-app     |                 LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-app     |                 LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-app     |                WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-app     |                  AND a.attnum > 0 AND NOT a.attisdropped
loomio-app     |                ORDER BY a.attnum
loomio-app     | ' duration=38.60 view=4.42 db=6.46
loomio-app     |
loomio-app     | ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "ahoy_visits" does not exist
loomio-app     | LINE 8:                WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-app     |                                           ^
loomio-app     | :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-app     |                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-app     |                      c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-app     |                 FROM pg_attribute a
loomio-app     |                 LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-app     |                 LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-app     |                 LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-app     |                WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-app     |                  AND a.attnum > 0 AND NOT a.attisdropped
loomio-app     |                ORDER BY a.attnum
loomio-app     | ):
loomio-app     |
loomio-app     | app/helpers/current_user_helper.rb:26:in `associate_user_to_visit'
loomio-app     | app/helpers/locales_helper.rb:8:in `use_preferred_locale'
loomio-app     | app/helpers/locales_helper.rb:3:in `process_time_zone'
loomio-app     | source=rack-timeout id=509cbcc7-d6ce-46de-aab5-96730842fb50 timeout=15000ms service=115ms state=completed
loomio-nginx   | nginx.1    | loomio.49grad-mainz.de 95.89.76.82 - - [11/Dec/2020:12:16:52 +0000] "GET /dashboard HTTP/2.0" 500 672 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
loomio-app     | source=rack-timeout id=565e637a-2f63-4258-9e12-18a314c551c5 timeout=15000ms state=ready
loomio-app     | Can't verify CSRF token authenticity.
loomio-db      | ERROR:  relation "ahoy_visits" does not exist at character 566
loomio-db      | STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-db      |                             pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-db      |                             c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-db      |                        FROM pg_attribute a
loomio-db      |                        LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-db      |                        LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-db      |                        LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-db      |                       WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-db      |                         AND a.attnum > 0 AND NOT a.attisdropped
loomio-db      |                       ORDER BY a.attnum
loomio-db      |
loomio-app     | method=POST path=/bhoy/visits format=*/* controller=Ahoy::VisitsController action=create status=200 duration=12.68 view=0.41 db=18.85
loomio-app     | source=rack-timeout id=565e637a-2f63-4258-9e12-18a314c551c5 timeout=15000ms service=37ms state=completed
loomio-nginx   | nginx.1    | loomio.49grad-mainz.de 95.89.76.82 - - [11/Dec/2020:12:16:52 +0000] "POST /bhoy/visits HTTP/2.0" 200 128 "https://loomio.49grad-mainz.de/dashboard" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
loomio-app     | source=rack-timeout id=8ec39e52-2f57-455f-b60c-4ac09432a5b9 timeout=15000ms state=ready
loomio-app     | Can't verify CSRF token authenticity.
loomio-db      | ERROR:  relation "ahoy_visits" does not exist at character 566
loomio-db      | STATEMENT:                SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-db      |                             pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-db      |                             c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-db      |                        FROM pg_attribute a
loomio-db      |                        LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-db      |                        LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-db      |                        LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-db      |                       WHERE a.attrelid = '"ahoy_visits"'::regclass
loomio-db      |                         AND a.attnum > 0 AND NOT a.attisdropped
loomio-db      |                       ORDER BY a.attnum
loomio-db      |
loomio-app     | method=POST path=/bhoy/events format=*/* controller=Ahoy::EventsController action=create status=200 duration=21.67 view=0.82 db=6.41
loomio-app     | source=rack-timeout id=8ec39e52-2f57-455f-b60c-4ac09432a5b9 timeout=15000ms service=27ms state=completed
loomio-nginx   | nginx.1    | loomio.49grad-mainz.de 95.89.76.82 - - [11/Dec/2020:12:16:52 +0000] "POST /bhoy/events HTTP/2.0" 200 28 "https://loomio.49grad-mainz.de/dashboard" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
RG

Rob Guthrie Fri 11 Dec 2020

Hi @Giuseppe - it looks like your database is corrupt or missing. It's saying it cant find a table.

Did you run docker-compose down before copying the files?

In theory you should be able to copy the loomio-deploy folder and all it's contents to a new location and boot it up, if you shutdown the services first.

If problems persist you can dump the database:

docker exec loomio-db su - postgres -c 'pg_dump -O -Fc loomio_production -f /pgdumps/loomio_production.dump'

which writes the file to a pgdumps folder on your server

then copy that file, and restore it on the other server:

docker exec loomio-db su - pg_restore --verbose --clean --no-acl --no-owner -d loomio_production /pgdumps/loomio_production.dump

the restore command might need a little tuning, and both of these lines should be in the readme.

G

Giuseppe Sun 13 Dec 2020

Thanks @Rob Guthrie for the hint and your time. I will try this.

I shut down the services before copying the folder, but I restarted it on the old server in the meanwhile - maybe this was a mistake.

I will report about the outcome

G

Giuseppe Fri 18 Dec 2020

@Rob Guthrie - I tried again with a blank, minimal server. I stoped the services on the old server with "docker-compose down". Then I copied the folder to the new server and started docker with docker-compose up -d - same result: Internatl Server Error :(.

I tried to dump the database, but your command is giving me "permission denied". Do you have an idea why?

sudo docker exec loomio-db su - postgres -c 'pgdump -O -Fc loomioproduction -f /pgdumps/loomio_production.dump') 
G

Giuseppe Fri 18 Dec 2020

Oh wow. It works now. I think I just forgot to create the swapfile on the new server. I did everything again and not it seems to start working. 🎉

RG

Rob Guthrie Fri 18 Dec 2020

Congrats. Nice job of sticking with it!