Issue with CouchDB Migration: Failed to Connect

Hello Community,

We are currently facing an issue with my CouchDB migration process, and I’m seeking some assistance to resolve it. Here are the details of the problem, whenever, I run the migration scripts.

Error Message:
An unexpected error occurred: Failed to connect to CouchDb. Please verify that the COUCH_URL provided is reachable through the Docker network.

I’ve set the COUCH_URL accordingly:
export COUCH_URL=https://medic:password@172.18.0.3:5984

Despite ensuring that the COUCH_URL is correctly configured, atleast from where I stand, the issue persists. I have verified that all these executions are happening within the Docker network context. However, it seems like something else might be missing.

Thank you,
George

@gk0harris - sorry to hear your having issues with your migration - that sounds frustrating!

Can you give some more details about your setup?

  1. What CHT Core version are you one, and which version are you trying to go to?
  2. Is this an in-place upgrade or are you moving from an server with CHT older version to a server with CHT newer version ?
  3. Is this single or multi-node CouchDB?
  4. Can you link to the documentation you’re following and specify the last step you followed before seeing the error?

Thanks!

1 Like

@mrjones - Thank you for your prompt response. Here are the details regarding the CouchDB migration issue:

What CHT Core version are you one, and which version are you trying to go to?
I am currently on version 3.17.2 and attempting to upgrade to version 4.0.0.

Is this an in-place upgrade or are you moving from an server with CHT older version to a server with CHT newer version ?
I am using a single-node CouchDB setup.

Can you link to the documentation you’re following and specify the last step you followed before seeing the error?
I am following the migration guide provided in the documentation here. The migration process fails at this step: docker-compose run couch-migration pre-index-views 4.0.0, where pre-indexing of views in preparation for the upgrade happens.

Thank you,
George.

Thanks for the details! This is really helpful. While I’ll need to ask some other teammates for help on the specific trouble shooting, I do recommend going to at least 4.0.1 as it has important fixes we on top of 4.0.0.

Otherwise, @henok or @diana or @hareet or @Lorena_Rodriguez - when you get a sec can you suggest a next step for George to take? Thanks!

1 Like

Hi @gk0harris

Checking your COUCH_URL, have you verified that this URL is indeed accessible? You should be able to curl it. My suspicion is that CouchDb is not available through https and you’d need to change the URL to:

export COUCH_URL=http://medic:password@172.18.0.3:5984

In any case, the URL that you pass as this environment variable should be accessible and you can easily check this via curl or in your browser.

Please let us know when you make progress on this!

1 Like

Hello @Diana,- sorry for the delay in providing feedback. we managed to overcome the previous hurdle, and it turned out that the issue was related to the URL itself. Thanks to the valuable insights provided here, we’ve successfully navigated through several migration steps as outlined in the documentation.

However, we’ve encountered a new challenge at the step labeled f) Change metadata to match the new CouchDb node. I once again reach out to this community in the hope of receiving guidance on how to address this particular step.

Your assistance is greatly appreciated.
George

Hi @george

I think that the URL that you are passing to the migration container could be the cause here. can you please share the URL?

@diana, having same issues with COUCH_URL, tried using the current password on docker-compose file but can’t connect using curl, thus can’t run the command
docker-compose run couch-migration pre-index-views .

Have tried to change the password from
/srv/settings/medic-core/couchdb/local.ini for the user medic and still not working, any other options of getting the correct password for couchDB?

Running supervisor-inspect returns couchDB up as below:

I have checked and the couchDB server is running:

Hi @oyierphil , your compose file that you are using to run couch-migration should be something like this.

version: '3.9'
services:
  couch-migration:
    image: public.ecr.aws/medic/couchdb-migration:1.0.3
    networks:
      - your_medic-net 
    environment:
      - COUCH_URL=http://medic:password@haproxy:5984/
      - COUCH_CLUSTER_PORT

networks:
  your_medic-net: 
    name: your_medic-net 
    external: true

Please note the haproxy on COUCH_URL.
You can see what’s your network name by runing sudo docker network ls.

Let us know if you’re still facing issue.

@yuv, running sudo docker network ls brings the following networks,

Following Migration from CHT 3.x to CHT 4.x | Community Health Toolkit Step 1 for downloading the compose file whose contents are as below:

version: '3.9'
services:
  couch-migration:
    image: public.ecr.aws/medic/couchdb-migration:1.0.3
    networks:
      - cht-net
    environment:
      - COUCH_URL
      - COUCH_CLUSTER_PORT
networks:
  cht-net:
    name: ${CHT_NETWORK:-cht-net}
    external: true

The network name is cht-net, I provided the Couch_URL in .env file, but when running
curl http://medic:password@haproxy:5984/

I get the error 
`An unexpected error occurred Error: Failed to connect to CouchDb. Please verify that the COUCH_URL provided is reachable through docker network.`

Would appreciate your insights

@yuv, we had a session with Josh and managed to migrate to CHT 4.9, we used the CHT 3.17 CouchDB login details as the CouchURL, but without the port number and we followed the documentation to completion, we are now good, and the current version supports repeat groups and related functions, so our app works as expected, always appreciate the support.

2 Likes