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
if not text:
        return []
    return [item.strip() for item in text.split(",")]
def get_bool_from_env(name: str, default_value: bool) -> bool:
    if name in os.environ:
        value = os.environ[name]
        try:
            return bool(strtobool(str(value)))
        except ValueError as e:
            raise ValueError(f"{value} is an invalid value for {name}, expected boolean") from e
    return default_value
def print_warning(warning_lines: Sequence[str]):
    highlight_length = min(max(map(len, warning_lines)) // 2, shutil.get_terminal_size().columns)
    print("\n".join(("", "🔻" * highlight_length, *warning_lines, "🔺" * highlight_length, "",)), file=sys.stderr)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = get_bool_from_env("DEBUG", False)
TEST = "test" in sys.argv or get_bool_from_env("TEST", False)  # type: bool
SELF_CAPTURE = get_bool_from_env("SELF_CAPTURE", DEBUG)
SHELL_PLUS_PRINT_SQL = get_bool_from_env("PRINT_SQL", False)
SITE_URL = os.getenv("SITE_URL", "http://localhost:8000").rstrip("/")
if DEBUG:
    JS_URL = os.environ.get("JS_URL", "http://localhost:8234/")
else:
    JS_URL = os.environ.get("JS_URL", "")
PLUGINS_INSTALL_VIA_API = get_bool_from_env("PLUGINS_INSTALL_VIA_API", True)
PLUGINS_CONFIGURE_VIA_API = PLUGINS_INSTALL_VIA_API or get_bool_from_env("PLUGINS_CONFIGURE_VIA_API", True)
PLUGINS_CELERY_QUEUE = os.environ.get("PLUGINS_CELERY_QUEUE", "posthog-plugins")
PLUGINS_RELOAD_PUBSUB_CHANNEL = os.environ.get("PLUGINS_RELOAD_PUBSUB_CHANNEL", "reload-plugins")