502 Bad Gateway and failed to create local setup

Hi @Arafat

Welcome to the CHT forum!

To better understand what’s going on with your instance, can you please share the logs of the CHT service containers?
To debug, I’d start by looking for errors in API logs, and go from there.


1 Like

Thank you for reaching out.
Here are the API logs

Hi @Arafat

It looks like API is trying to connect to haproxy, but can’t reach it. This can be either caused by haproxy directly, or by CouchDb failing to start. Can you please check haproxy logs to see if anything becomes obvious?

As a potential quick fix, you could try to restart the whole setup process. Here are some steps that you can follow: Error 502 when running local CHT instance - #13 by mrjones

Here are the haproxy logs

Let me try mrjones method and revert.

Just to mention as well,
After multiple attempts and failing to set up with the documentation,i started following a video on youtube by medic created 10 months ago, I pulled from the previous commits of cht-core repo .yml before the yml was removed. The local environment worked properly and the application but also faced a block, after creating a user and I try to login with the new user, the application would break showing a connection error and when checking console logs, something about openSSL certificates.

So with your advice, should I continue with this current setup or should I do a previous version and also share the errors I encountered then?

Same issue with mrjones solution

Hi @Arafat,
I am wondering if the issue you are facing can be related to other issue earlier since you mentioned you faced a block after creating a user. If you are using Google Chrome, could you please try Mozilla Firefox and check if the error persists?

Thank you @niraj

I tried Microsoft Edge, and the same problem happened with logging in as a new user. Let me try Mozilla and see.
In the meantime, I am also going to try this Unable to load the application with a CHW user - #2 by binod since it is related to the problem.

Thanks alot

1 Like

Hi @Arafat ,
I noticed that you have marked the issue as solved. That’s great.

Could you please add few details on how you were able to resolve so that it is easier for someone who may be facing similar issue?

I faced a similar problem, the API,Nginx, and logs are similar to what @Esther_Moturi raised in this thread however, my couch db logs read differently as shown below

I have tried docker kill for all cht containers then up again as suggested in that thread, I have also tried using Mozilla firefox all to no avail. Any possible solution?

Hi @kembo

Could you please use this script cht-core/scripts/compress_and_archive_docker_logs.sh at master · medic/cht-core · GitHub and share the logs of your containers?

Hello @niraj

Sorry for the late response, I managed to solve that particular blocker by using ngrok in this guide https://github.com/medic/cht-core/blob/6d3a5eb60f5411c5a8c2f808ffee8a5301806c36/DEVELOPMENT.md from this a new user can login into the system


Then for the local setup, the tutorial on https://docs.communityhealthtoolkit.org/apps/tutorials/local-setup/ didn’t work for me, I failed to create the local environment, I had to build using the docker-compose file that was previously in the cht-core repo (in the previously committed branch) before it was removed. That way my local environment was set up.

1 Like

Hi @Arafat , thank you for sharing details.

@Arafat - I wanted to add a follow up on this:

  • The developer set up guide you referenced in the old commit, now lives here. You can references this as it’s a living document that will be kept up to date.
  • on that same developer set up guide, it’s recommended to use the great nginx-local-ip project instead of ngrok, unless you explicitly need to share your instance with a remote user.


Hey @mrjones
Thank you for the response, but when I try to use nginx , I get the same previous error unlike ngrok

Gotcha - thanks for the update! Sorry that didn’t work out for you.

Hi @Arafat

Can you please check browser logs and share what error is reported?

Yes please

Hi @Arafat

It looks like your credentials stored in the browser cookie somehow expired. Could you try clearing browser cache and logging in again? Or trying a different browser?

Hi @diana

I have tried two other browsers, the application opens but after logging when I load a hospital it hangs and just keeps loading

Then also when I try to login with a new user I had created previously, it still hangs, stay on that page as shown below

Yet using ngrok, the app seems to work fine