Could not connect with Form Server

1. What is the issue? Please be detailed.

Preview a form: got "Could not connect with Form Server"

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

  1. Start the docker compose locally and wait for all services to be up without any problems
  2. Upload a valid form
  3. Preview the form

3. What have you tried to fix the issue?

Using help from this section: https://docs.getodk.org/central-troubleshooting/#preview-could-not-connect-with-server

But did not help; the problem is still there

4. Upload any forms or screenshots you can share publicly below.

To self-host Central, you must have a fully-qualified domain name (e.g., central.example.com) mapped to your server. If you are using an IP or localhost, you'll have these kinds of problems. What do you have as your DOMAIN and SSL_TYPE in your .env file?

@yanokwa, Thanks for your help. However, I still face the same problem and here are steps I tried

1. Update .env file

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

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

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

# Do not change if using SSL_TYPE=letsencrypt
HTTP_PORT=8099
HTTPS_PORT=4433

2. Update hosts file

127.0.0.1 myodk.local.net

3. Create Self-Sign Cert for myodk.local.net

4. Install the certificate

Install the cert on step 3 to Trusted Root Certification Authorities

5. Update the deamon.json

5.1 run this command: cat /run/systemd/resolve/resolv.conf
Add : "dns": [
"result from step 5.1"
],

And still have the same problem as before.

Hello @jdang, this issue usually happens when Enketo (the form preview tool) can't connect to the ODK Central backend, often due to network or domain misconfiguration. Even if all your Docker services are running correctly, the preview won’t work properly if Central is not set up with a fully-qualified domain name (FQDN) like central.example.com. Using just an IP address or localhost for local development can break WebSocket connections needed for Enketo to work; that is why @yanokwa strongly recommended using an FQDN for any Central deployment, even if it's just for local testing.

To fix this, set up a domain name (e.g., using a free DNS service like DuckDNS) map it to your server's IP, and update the DOMAIN variable in your .env file accordingly. After that, run docker-compose down and then docker-compose up -d to restart everything. Once this is in place, the form preview should work smoothly without throwing the “Could not connect with Form Server” error.

Let me know how it goes.

@brian_achaye, Here are the steps that I try, and the result is the same. Did I miss anything?

Step 1: Create a public domain for testing: my-odk-central-xx.duckdns.org
testing

PS C:\>  my-odk-central-xx.duckdns.org

Pinging my-odk-central-xx.duckdns.org [my-public-ip] with 32 bytes of data:
Reply from [my-public-ip]: bytes=32 time=5ms TTL=63
Reply from [my-public-ip]: bytes=32 time=5ms TTL=63
Reply from [my-public-ip]: bytes=32 time=5ms TTL=63

Ping statistics for [my-public-ip]:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 5ms, Maximum = 6ms, Average = 5ms
PS C:\>

Step 2: Map the newly created domain to the local machine

# Update the hosts file
127.0.0.1 my-odk-central-xx.duckdns.org
127.0.0.1 www.my-odk-central-xx.duckdns.org

Step 3: Update the .env file

# Use fully qualified domain names. Set to DOMAIN=local if SSL_TYPE=selfsign.
DOMAIN=my-odk-central-xx.duckdns.org

# Used for Let's Encrypt expiration emails and Enketo technical support emails
SYSADMIN_EMAIL=my-admin@my-domain.com

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

# Do not change if using SSL_TYPE=letsencrypt
HTTP_PORT=8099
HTTPS_PORT=4433

Step 4: restart the docker engine, rebuild the docker-compose

Step 5: Create a self-sign Cert for my-odk-central-xx.duckdns.org and install

Step 6: Try to preview a form

===> Could not connect with Form Server

Your myodk.local.net configuration will not work because the Enketo container doesn't have a mapping from myodk.local.net to your IP. Here's what I would do..

  1. Remove the DNS changes you made to /etc/docker/daemon.json and restart Docker.

    cd ~/central
    docker compose stop
    systemctl restart docker
    docker compose up --detach
    
  2. Connect to the Enketo container and run the following to check if Enketo can reach Nginx. You should get a 1 output on the curl command if it's working.

    # connect to enketo container
    cd ~/central
    docker exec -it central-enketo-1 bash
    
    # install curl
    apt update
    apt install curl --assume-yes
    
    # run curl. 1 means everything is working,
    curl --silent --insecure https://myodk.local.net | grep --count getodk.org
    
    # clean up
    apt remove curl --assume-yes
    apt autoremove --assume-yes
    
  3. Try adding a host mapping to your docker-compose.yml. Replace x.x.x.x with your private IP. What this does is add a /etc/hosts mapping to your Enketo container.

      enketo:
        volumes:
          - secrets:/etc/secrets
    ...
        extra_hosts:
          - 'myodk.local.net:x.x.x.x'
    
  4. Rebuild and try the form preview. One caveat is that I don't know how Enketo will behave with a self-signed cert.

    cd ~/central
    docker compose build
    docker compose stop
    docker compose up --detach
    
2 Likes

@yanokwa, assume the domain we use the myodk.local.net and mapping to the hosts file: 127.0.0.1 myodk.local.net, the fully qualified domain for my local, not the public domain

Unfortunately, the following command returns 0, not 1

run curl. 1 means everything is working,

curl --silent --insecure https://myodk.local.net | grep --count getodk.org

I'm not sure that the way our IT department configures our laptops could cause problems.
We are thinking about deploying the ODK-Central-Dev Env to Azure.

Regards,

Jdang

If you want a dev environment for contributing code to ODK, then https://github.com/getodk/central?tab=readme-ov-file#contributing is what I'd recommend. It'd probably work on a corporate laptop.

If you want a dev environment for playing around with ODK (e.g., trying features and APIs), then deploying to Azure as you've suggested is going to be your best bet.

@yanokwa , Does this branch include the front end? At this time, we want to have all the service packs together unless you have documentation to set up the front-end and integration with the backend.

Hi @yanokwa ,

I pulled the next branch, and I got this problem when trying to view the form:

So, neither the master nor the next branches support Docker Compose?

Regards,

Jdang