In local development StatsD is raising `OSError: [WinError 10049] The requested address is not valid in its context` when env variable `STATSD_HOST` is not set. This seems to just be a Windows issue as the error suggests, because I can't get it to happen inside Docker.

This is happening because the default empty string of `settings.STATSD_HOST` gets set as the default host of `statsd.Connection`, and the empty string is not a valid host name in Windows.

https://github.com/PostHog/posthog/blob/1357df0c137e36478be19a1b8739dcdba93d2327/posthog/settings.py#L181
https://github.com/PostHog/posthog/blob/1ec12f26e707489e77077be029ddb79ceeefd944/posthog/celery.py#L35

StatsD sets the default `host` value to `'localhost'`, and restoring this default fixes the errors. I can make a PR tomorrow, but just wanted to check on this:
https://github.com/PostHog/posthog/blob/1357df0c137e36478be19a1b8739dcdba93d2327/posthog/settings.py#L217-L219

I can change it to `if os.environ.get("STATSD_HOST", False):`, but it might make more sense as a separate env variable like `STATSD_ENABLED`. My only concern with that is it's probably a breaking change. Are there any better options?



posthog/settings.py
# Clickhouse Settings
CLICKHOUSE_TEST_DB = "posthog_test"
CLICKHOUSE_HOST = os.environ.get("CLICKHOUSE_HOST", "localhost")
CLICKHOUSE_USERNAME = os.environ.get("CLICKHOUSE_USERNAME", "default")
CLICKHOUSE_PASSWORD = os.environ.get("CLICKHOUSE_PASSWORD", "")
CLICKHOUSE_DATABASE = CLICKHOUSE_TEST_DB if TEST else os.environ.get("CLICKHOUSE_DATABASE", "default")
CLICKHOUSE_CA = os.environ.get("CLICKHOUSE_CA", None)
CLICKHOUSE_SECURE = get_bool_from_env("CLICKHOUSE_SECURE", not TEST and not DEBUG)
CLICKHOUSE_VERIFY = get_bool_from_env("CLICKHOUSE_VERIFY", True)
CLICKHOUSE_REPLICATION = get_bool_from_env("CLICKHOUSE_REPLICATION", False)
CLICKHOUSE_ENABLE_STORAGE_POLICY = get_bool_from_env("CLICKHOUSE_ENABLE_STORAGE_POLICY", False)
CLICKHOUSE_ASYNC = get_bool_from_env("CLICKHOUSE_ASYNC", False)
_clickhouse_http_protocol = "http://"
_clickhouse_http_port = "8123"
if CLICKHOUSE_SECURE:
    _clickhouse_http_protocol = "https://"
    _clickhouse_http_port = "8443"
CLICKHOUSE_HTTP_URL = _clickhouse_http_protocol + CLICKHOUSE_HOST + ":" + _clickhouse_http_port + "/"
IS_HEROKU = get_bool_from_env("IS_HEROKU", False)
KAFKA_URL = os.environ.get("KAFKA_URL", "kafka://kafka")
LOG_TO_WAL = get_bool_from_env("LOG_TO_WAL", True)
_kafka_hosts = KAFKA_URL.split(",")
KAFKA_HOSTS_LIST = []
for host in _kafka_hosts:
    url = urlparse(host)
    KAFKA_HOSTS_LIST.append(url.netloc)
KAFKA_HOSTS = ",".join(KAFKA_HOSTS_LIST)
POSTGRES = "postgres"
CLICKHOUSE = "clickhouse"
PRIMARY_DB = os.environ.get("PRIMARY_DB", POSTGRES)  # type: str