Failed to connect to my Hub http://HOST_IP:8081 at Is it running?

I am running jupyterhub on an ec2 instance inside docker with the following

c = get_config()

c.Authenticator.admin_users = {'USER_NAME'}

c.JupyterHub.spawner_class = 'awsspawner.EcsTaskSpawner'

c.Spawner.cluster_name = 'staging-notebook-cluster'

c.Spawner.ecs_task_definition = 'jupyter-scipy-notebook'

c.Spawner.port = 8000

c.Spawner.http_timeout = 60 

#c.JupyterHub.hub_ip = ''

#c.JupyterHub.hub_connect_ip = 'HOST_IP'

# shutdown the server after no activity for an hour

c.NotebookApp.shutdown_no_activity_timeout = 60 * 60

# shutdown kernels after no activity for 20 minutes

c.MappingKernelManager.cull_idle_timeout = 20 * 60

# check for idle kernels every two minutes

c.MappingKernelManager.cull_interval = 2 * 60

I am using custom spawner to spawn notebooks on ecs cluster. Hub is able to run task on ecs cluster but the task if failing with the following error

[E 2020-04-29 09:20:14.444 singleuser:438] Failed to connect to my Hub at http://HUB_HOST_IP:8081/jupyter/hub/api (attempt 5/5). Is it running?
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/jupyterhub/", line 432, in check_hub_version
        resp = await client.fetch(self.hub_api_url)
    ConnectionRefusedError: [Errno 111] Connection refused

Following env variables are used in the task
“Env”: [

I have tried changing the JUPYTERHUB_ACTIVITY_URL and JUPYTERHUB_API_URL port to 8000 too still it is failing. I changed that because telnet is working for 8000 port only from the ecs cluster instance

My hub is running in docker inside an ec2 instance and it is spawning single-user notebook in other instances of ecs cluster