Central on localhost

1. What is the issue? Please be detailed.
Unable to connect on localhost:9000

2. What steps can we take to reproduce this issue?
.env file content

# Use fully qualified domain names. Set to DOMAIN=local if SSL_TYPE=selfsign.
DOMAIN=localhost

# Used for Let's Encrypt expiration emails and Enketo technical support emails
SYSADMIN_EMAIL=myemail@yahoo.com

# Options: letsencrypt, customssl, upstream, selfsign
SSL_TYPE=upstream

# Do not change if using SSL_TYPE=letsencrypt
HTTP_PORT=9000
HTTPS_PORT=9443

All containers are up and running

Error message of central-service-1 container

Error: getaddrinfo EAI_AGAIN postgres14
*** Error starting ODK! ***
After attempting to automatically migrate the database, we have detected unapplied migrations, which suggests a problem with the database migration step. Please look in the console above this message for any errors and post what you find in the forum: https://forum.getodk.org/
wait-for-it: waiting 15 seconds for postgres14:5432

But logs of central-postgres14-1 seems ok

pat@pat-pc ~/d/c/central (master)> podman logs central-postgres14-1
Tue Dec  3 01:21:50 PM GMT 2024 [start-postgres.sh] Starting postgres...

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-12-03 13:21:50.325 UTC [1] LOG:  starting PostgreSQL 14.10 (Debian 14.10-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-12-03 13:21:50.326 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-12-03 13:21:50.326 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-12-03 13:21:50.327 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-12-03 13:21:50.329 UTC [24] LOG:  database system was shut down at 2024-12-03 13:21:03 UTC
2024-12-03 13:21:50.333 UTC [1] LOG:  database system is ready to accept connections

Any idea? I'm working with

  • podman version 4.9.3
  • docker compose version V2.29.7
  • Ubuntu 24.04.1 LTS
1 Like

For me, the containers can run with DOMAIN=localhost, and one can access the Central interface with it.

Then I attempted to use ODKCollect with that setup. Getting it to contact Central using a QR code works (with an Android device with ADB enabled - use adb reverse tcp:yourCentralport tcp:yourCentralport to tunnel from the Android device localhost interface).
But the XML in the formList OpenRosa endpoint contains URLs such as https://localhost:8443/..., so in the end, without further tinkering, it'll break on that.

Thanks for your answers!

I've changed to a specific DOMAIN=odkcentral.local, but it doesn't change anything. And added this domain in my /etc/hosts file.

I think it is a network issue.

podman logs central-enketo-1

node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo EAI_AGAIN enketo_redis_cache
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26)
Emitted 'error' event on RedisClient instance at:
    at RedisClient.on_error (/srv/src/enketo/node_modules/redis/index.js:342:14)
    at Socket.<anonymous> (/srv/src/enketo/node_modules/redis/index.js:223:14)
    at Socket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'enketo_redis_cache'
}

Node.js v20.17.0
Worker 12558 sadly passed away. It will be reincarnated.

I've tried by adding a specific network and adding it on each service in docker-compse.yml file, but it doesn't change anything

    networks:
      - myodk

I'm wondering what I have to put for the SSL_TYPE variable in .env file?
upstream or selfsign?

# Options: letsencrypt, customssl, upstream, selfsign
SSL_TYPE=upstream

Ha, you don't give up! :smile:

So for your reference, I have only this in my .env:

DOMAIN=localhost
SYSADMIN_EMAIL=administrator@example.com
SSL_TYPE=upstream
HTTP_PORT=8080
HTTPS_PORT=8443

Your problem seems (for now) unrelated to these settings; for you the problem seems to be that central-enketo-1 keeps crashing (and restarting) because on bootup it tries to make a connection to enketo_redis_cache, which cannot be resolved, which can have a number of causes, one of which is that that service itself can keep crashing (which, in turn, can have a number of causes), which results in the docker/podman DNS server not registering that hostname. This happened to me, and one of the causes I found I've filed here.

I hope that helps you a bit further along in your efforts!

1 Like

Yesss, it works! Many thanks for your help :slight_smile: Best wishes

Hey @openHBP / @Nonsequitur !

I was wondering if you were able to use Enketo (for form previews) when hosted ODK Central (using docker, not the development environment) locally? I tried the same and I am stuck @ form server could not be found (also here: Could not connect with Form Server Preview). Also, I am not sure if I am correct but it seems like the http (non SSL) access to Central no more works with the latest release and is blocked via server block in nginx?! Then how come did the localhost thing work with "upstream"?! :thinking:

Please let me know..

Indeed, the Enketo preview is not working but I usually use https://getodk.org/xlsform/ to validate my forms.

And for your second question, I'm not sure to understand. ODK central should run locally on your computer. The tricky part now it to be able to view and submit forms from your smartphone. For that, you must run ODK central on the IP address provided by the WiFi you're connected on with your SmartPhone. So .env file must define a certain IP address for the DOMAIN ie: DOMAIN=10.15.99.87. For now, I did not succeed... But I just wanted to see ODK central website look and how it works with projects.

1 Like

Hmm, I see. Thank you very much for the clarification.

Nevertheless, I guess, I am aware of a workaround to use an internal static IP (like DOMAIN=10.15.99.87) to let ODK Collect connect to the ODK Central server over localhost. I haven't tested it yet, just an idea, but I believe that if we make Central (hosted over localhost) run behind a reverse proxy and disable the firewall, we can bypass that "Central needs a qualified domain name to function" restriction and pair the same with ODK Collect using an IP over the same network (using http and not https). But, we must use Central version less than or equal to v2024.2.1 to achieve the same.

Anyways, if you ever stumble upon a solution to make Enketo work with this setup, please let me know. I really don't wanna dive into it's documentation by myself. :neutral_face:

Se puede conectar odk collect a odk central? Odk central esta instalado en mi maquina local.

Si, puede, pero no es facil. Eso modo es suelo para development y testing.

Segue el documentacion para development local y despues utiliza adb forward para projectar el puerte TCP port de tu server a través de un cable USB dentro de la tableta. De modo que, puede utilizar el codo QR para configurarlo.

Para la mayoría de los usuarios es mas mas mejor este método: https://docs.getodk.org/central-install-digital-ocean/