Trouble logging in with newly created admin user in CouchDB v 3.6.1

Hello,

I recently created an admin user in CouchDB version 3.6.1, but I’m having trouble logging in with the newly created user. Despite following the steps correctly, I still can’t seem to access my account.

Has anyone encountered this problem before, and if so, how did you resolve it? Any tips or suggestions would be greatly appreciated.

Thank you.

Hello @Steve_Roy

Can you please provide more details about your setup? Which steps are you following?

Thanks!

Hello @diana

Thank you for your response. Here are some more details about my setup and the steps I’ve followed:

However, when I try to log in with the new admin user credentials, I’m unable to access my account.

I’m not sure what I’m doing wrong or why I’m unable to log in. Any help or suggestions would be appreciated.

Thank you.

Hi @Steve_Roy

The instructions on the CouchDb site include creating the admin by manually changing the config file or by calling the _config endpoint.
I’ve just tested creating an admin by calling the endpoint, and I was able to log in successfully.
For reference, this is how I created my new admin:

curl -k -X PUT https://admin:pass@127.0.0.1/_node/couchdb@127.0.0.1/_config/admins/architect -d '"medic.123"'

Are you creating the admin by manually editing the config file?

Hello @diana

Thank you for providing me with the useful information. I would like to inform you that I have attempted to create the admin accounts both manually by editing the config file, as well as by calling the _config endpoint. Although the admin accounts were created successfully, I am still unable to log in.

Many thanks.

Hi @Steve_Roy

What happens when you call the URL I have shared in the post above?
For manually editing the config file, could you please share exactly what steps you followed?

Thanks!

Hi @diana

Upon executing the URL, an empty string “” was received as the response. After examining the local.ini file, I confirmed that the user had been successfully created. An attempt was made to log in with the newly created user, however, access was not granted.

To perform the manual editing, I took the following steps:

  • Accessed the Docker container by executing the command “docker exec -it medic-os bash”
  • Modified the CouchDB local.ini file using the text editor Vim: “vim /srv/settings/medic-core/couchdb/local.ini”
  • Created a new admin user named “test” with a plaintext password
  • Restarted CouchDB
  • User was successfully created and hashed in local.ini file

Despite these efforts, logging in was still not successful.

Many thanks.

Hi @Steve_Roy

Does your username contain uppercase characters, by chance? (related: Initial user creation fails when CouchDB admin username contains uppercase characters · Issue #7142 · medic/cht-core · GitHub)

Could you also please share which version of the CHT you are running, so I can try to replicate this?
In one of the previous messages you mentioned running 4.x:

And in your latest message you mention medic-os, which was removed in 4.x

Thanks a lot!

@Steve_Roy after our conversation today I was able to recreate this behavior locally running CHT 3.6. I noticed this error in the api logs when trying (and failing) to login as a new admin:

REQ b14f2aad-093d-45b3-bbe8-def927cb4b09 ::1 - POST /medic/login HTTP/1.1
2023-02-23 14:40:11 ERROR: Error getting authCtx [object Object]
RES b14f2aad-093d-45b3-bbe8-def927cb4b09 ::1 - POST /medic/login HTTP/1.1 401 33 29.335 ms

I believe that you are facing this known issue that was fixed in 3.9. Unfortunatly, I do not know of any workaround for this behavior besides upgrading to 3.9+.

Hello @diana @jkuester

My apologies for the delayed response. As per your advice, we attempted to upgrade from version 3.6.1 to 3.16.0. However, it has been three days now, and I regret to inform you that the upgrade process has not been successful. Please see below for the status of the upgrade process:

As you can see, the upgrade process has been at a standstill for the past three days. In addition, the following are the current service statuses:

Package 'horticulturalist':
  Service 'horticulturalist':
    Status: Failure
    Up: 1 seconds, Restarts: 85105
    Attributes: watched, expected
    Service PID: None, Supervisor PID: 343

Package 'medic-api':
  Service 'medic-api':
    Status: Up
    Up: 201720 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 402, Supervisor PID: 386

Package 'medic-core':
  Service 'couchdb':
    Status: Up
    Up: 201720 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 446, Supervisor PID: 428
  Service 'nginx':
    Status: Up
    Up: 201720 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 507, Supervisor PID: 486
  Service 'openssh':
    Status: Up
    Up: 201720 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 580, Supervisor PID: 555

Package 'medic-couch2pg':
  Service 'medic-couch2pg':
    Status: Failure
    Up: 1 seconds, Restarts: 85585
    Attributes: watched, expected
    Service PID: None, Supervisor PID: 602

Package 'medic-rdbms':
  Service 'postgresql':
    Status: Up
    Up: 201720 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 663, Supervisor PID: 640

Package 'medic-sentinel':
  Service 'medic-sentinel':
    Status: Up
    Up: 201720 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 697, Supervisor PID: 688

Package 'system-services':
  Service 'cron':
    Status: Up
    Up: 201721 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 750, Supervisor PID: 736
  Service 'syslog':
    Status: Up
    Up: 201721 seconds, Restarts: 0
    Attributes: watched, running, expected
    Service PID: 789, Supervisor PID: 770

When I executed docker exec -it medic-os tail -n100 /srv/storage/horticulturalist/logs/horticulturalist.log I got the below error:

/srv/software/horticulturalist/node_modules/horticulturalist/src/index.js:119
  throw new Error(`Lock file already exists at ${lockfile.path()}.  Cannot start horticulturalising.`);
  ^

Error: Lock file already exists at /srv/storage/horticulturalist/.horticulturalist.lock.  Cannot start horticulturalising.
    at Object.<anonymous> (/srv/software/horticulturalist/node_modules/horticulturalist/src/index.js:119:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

Your assistance to this will be highly appreciated.

Many thanks

Hello @Steve_Roy

I’m not certain that this is the cause of your errors, but as of CHT v 3.9, CHT requires an additional dependency in medic-api, which needs to be part of your medic-os image: 3.9.0 release notes | Community Health Toolkit

We have a guide on how to upgrade your medic-os container.

Could you please check which version of medic-os you are running, to see if an upgrade is necessary?

Hello @diana

Thank you for sharing the Guide. Am running medic-os v 3.7 as per the below docker-compose excerpt.

version: '3.7'

services:
  medic-os:
    container_name: medic-os
    image: medicmobile/medic-os:cht-3.7-pre4

Many thanks

Hi @Steve_Roy

In this case, you’d have to upgrade your container in order to upgrade CHT further than 3.8.x.

Let me know if the steps to upgrade the container are clear.
Thanks!

Hi @diana

Yes, the steps are clear. I will execute and revert.

Many thanks.

Hello @diana,

I executed the steps and I could see significant progress as below

After some time It resulted into a 404 error

I have checked the couchdb logs and all is fine and even restarted the containers but still getting the 404 error. I really don’t understand what I am missing. Your assistance will be highly appreciated.

Many thanks.

Hi @Steve_Roy

I think the 404 is misleading, as it probably points to another error template missing. My guess that some required services didn’t come online all right. Could you please check API logs to see if the service is up?

Here are some instructions about how to get logs for various services: https://docs.communityhealthtoolkit.org/apps/guides/hosting/3.x/self-hosting/

2 Likes

Hello @diana

I would like to express my gratitude for your prompt response. After reviewing the medic-api logs, I was able to identify and address a few errors. Furthermore, I am pleased to report that the upgrade has been successfully completed and an admin user has been created, who was able to log in without any issues.

I would like to extend my sincerest appreciation to you and @jkuester for the invaluable assistance you have provided throughout this process. Your support has been instrumental in achieving this successful outcome, and I am truly grateful for your dedication and expertise.

Thank you again for your outstanding service.

4 Likes

This made my day @Steve_Roy ! Much appreciated!

2 Likes