[GH-ISSUE #499] Inconsistency in Documentation: ALLOWED_HOSTS #369

Closed
opened 2026-02-25 23:42:12 +03:00 by kerem · 3 comments
Owner

Originally created by @jandermannderkann on GitHub (Apr 17, 2021).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/499

Hi, i noticed that in the configuration Documentation for the ALLOWED_HOSTS variable it reads:

A list of strings representing the host/domain names that this site can serve.

yet the line right beneath shows an example:

ALLOWED_HOSTS=my-hc.example.org,alternative-name.example.org

which does not use Strings.

I propse to change the example to

ALLOWED_HOSTS="my-hc.example.org","alternative-name.example.org"

Originally created by @jandermannderkann on GitHub (Apr 17, 2021). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/499 Hi, i noticed that in the configuration Documentation for the ALLOWED_HOSTS variable it reads: > A list of strings representing the host/domain names that this site can serve. yet the line right beneath shows an example: > `ALLOWED_HOSTS=my-hc.example.org,alternative-name.example.org` which does not use Strings. I propse to change the example to `ALLOWED_HOSTS="my-hc.example.org","alternative-name.example.org"`
kerem closed this issue 2026-02-25 23:42:12 +03:00
Author
Owner

@cuu508 commented on GitHub (Apr 21, 2021):

Thanks for reporting!

Yes, the "A list of strings" bit makes it sound like it would accept data in Python notation. But the example is correct – the value should be a string with comma-separated host/domain names. I just updated the wording to hopefully make it less confusing.

<!-- gh-comment-id:824133164 --> @cuu508 commented on GitHub (Apr 21, 2021): Thanks for reporting! Yes, the "A list of strings" bit makes it sound like it would accept data in Python notation. But the example is correct – the value should be a string with comma-separated host/domain names. I just updated the wording to hopefully make it less confusing.
Author
Owner

@jandermannderkann commented on GitHub (Apr 26, 2021):

Thanks for looking into this.! :)
Im not entirely sure, my issue is resolved though.
I encountered this problem, when i put the following line into my local_settings:
ALLOWED_HOSTS="example.com"
which resulted in an error, while
ALLOWED_HOSTS=["example.com"] did not throw any errors.

Detailed Report:
Steps to reproduce:
Do fresh installation:
(mkdir /tmp/test && git clone https://github.com/healthchecks/healthchecks.git /tmp/test/hc && python3 -m venv /tmp/test/env && source /tmp/test/env/bin/activate && pip install --upgrade pip && pip install -r /tmp/test/hc/requirements.txt)
Step 1:
echo 'ALLOWED_HOSTS="localhost" ' > /tmp/test/hc/hc/local_settings.py && python /tmp/test/hc/manage.py runserver
goto localhost:8000 and see
Behavior:
Invalid HTTP_HOST header: 'localhost:8000'. You may need to add 'localhost' to ALLOWED_HOSTS.
look at settings information at bottom of page and see: ALLOWED_HOSTS | 'localhost'

expected behavior: no error page

<!-- gh-comment-id:826927905 --> @jandermannderkann commented on GitHub (Apr 26, 2021): Thanks for looking into this.! :) Im not entirely sure, my issue is resolved though. I encountered this problem, when i put the following line into my local_settings: `ALLOWED_HOSTS="example.com"` which resulted in an error, while ``ALLOWED_HOSTS=["example.com"]`` did not throw any errors. Detailed Report: **Steps to reproduce:** Do fresh installation: (`mkdir /tmp/test && git clone https://github.com/healthchecks/healthchecks.git /tmp/test/hc && python3 -m venv /tmp/test/env && source /tmp/test/env/bin/activate && pip install --upgrade pip && pip install -r /tmp/test/hc/requirements.txt`) **Step 1:** ``echo 'ALLOWED_HOSTS="localhost" ' > /tmp/test/hc/hc/local_settings.py && python /tmp/test/hc/manage.py runserver`` goto localhost:8000 and see **Behavior**: `Invalid HTTP_HOST header: 'localhost:8000'. You may need to add 'localhost' to ALLOWED_HOSTS.` look at settings information at bottom of page and see: `ALLOWED_HOSTS | 'localhost'` **expected behavior:** no error page
Author
Owner

@cuu508 commented on GitHub (Apr 26, 2021):

Thanks, appreciate the precise steps to reproduce.

The Server Configuration page describes the environment variables Healthchecks reads and uses. The syntax in environment variables and in local_settings.py is slightly different.

In environment variable you would use:

ALLOWED_HOSTS=host-a.com,host-b.org

In local_settings.py you would use:

ALLOWED_HOSTS = ["host-a.com", "host-b.org"]

There are two reasons I didn't want to use Python syntax in environment variables:

  • less worries about escaping special characters – square brackets, quotes, comma
  • I wanted the configuration syntax should be language-agnostic. You shouldn't need to know Python list syntax to set the environment variable
<!-- gh-comment-id:826953510 --> @cuu508 commented on GitHub (Apr 26, 2021): Thanks, appreciate the precise steps to reproduce. The [Server Configuration](https://healthchecks.io/docs/self_hosted_configuration/) page describes the _environment variables_ Healthchecks reads and uses. The syntax in environment variables and in local_settings.py is slightly different. In environment variable you would use: ALLOWED_HOSTS=host-a.com,host-b.org In local_settings.py you would use: ALLOWED_HOSTS = ["host-a.com", "host-b.org"] There are two reasons I didn't want to use Python syntax in environment variables: * less worries about escaping special characters – square brackets, quotes, comma * I wanted the configuration syntax should be language-agnostic. You shouldn't need to know Python list syntax to set the environment variable
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#369
No description provided.