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
else:
    REDIS_URL = os.environ.get("REDIS_URL", "")
if not REDIS_URL and os.environ.get("POSTHOG_REDIS_HOST", ""):
    REDIS_URL = "redis://:{}@{}:{}/".format(
        os.environ.get("POSTHOG_REDIS_PASSWORD", ""),
        os.environ.get("POSTHOG_REDIS_HOST", ""),
        os.environ.get("POSTHOG_REDIS_PORT", "6379"),
    )
if not REDIS_URL:
    raise ImproperlyConfigured(
        "Env var REDIS_URL or POSTHOG_REDIS_HOST is absolutely required to run this software.\n"
        "If upgrading from PostHog 1.0.10 or earlier, see here: "
        "https://posthog.com/docs/deployment/upgrading-posthog#upgrading-from-before-1011"
    )
# Only listen to the default queue "celery", unless overridden via the cli
# NB! This is set to explicitly exclude the "posthog-plugins" queue, handled by a nodejs process
CELERY_QUEUES = (Queue("celery", Exchange("celery"), "celery"),)
CELERY_DEFAULT_QUEUE = "celery"
CELERY_IMPORTS = ["posthog.tasks.webhooks"]  # required to avoid circular import
if PRIMARY_DB == CLICKHOUSE:
    try:
        from ee.apps import EnterpriseConfig  # noqa: F401
    except ImportError:
        pass
    else:
        CELERY_IMPORTS.append("ee.tasks.webhooks_ee")
CELERY_BROKER_URL = REDIS_URL  # celery connects to redis
CELERY_BEAT_MAX_LOOP_INTERVAL = 30  # sleep max 30sec before checking for new periodic events
CELERY_RESULT_BACKEND = REDIS_URL  # stores results for lookup when processing
CELERY_IGNORE_RESULT = True  # only applies to delay(), must do @shared_task(ignore_result=True) for apply_async