mitmproxy/mitmproxy · error · ValueError

Invalid configuration file ({conf_path}): {e}

Error message

Invalid configuration file ({conf_path}): {e}

What it means

Error "Invalid configuration file ({conf_path}): {e}" thrown in mitmproxy/mitmproxy.

Source

Thrown at mitmproxy/proxy/mode_servers.py:369

        if not conf_path.exists():
            conf_path.parent.mkdir(parents=True, exist_ok=True)
            conf_path.write_text(
                json.dumps(
                    {
                        "server_key": mitmproxy_rs.wireguard.genkey(),
                        "client_key": mitmproxy_rs.wireguard.genkey(),
                    },
                    indent=4,
                )
            )

        try:
            c = json.loads(conf_path.read_text())
            self.server_key = c["server_key"]
            self.client_key = c["client_key"]
        except Exception as e:
            raise ValueError(f"Invalid configuration file ({conf_path}): {e}") from e

        # error early on invalid keys
        self.pubkey = mitmproxy_rs.wireguard.pubkey(self.client_key)
        _ = mitmproxy_rs.wireguard.pubkey(self.server_key)

        await super()._start()

        conf = self.client_conf()
        assert conf
        logger.info("-" * 60 + "\n" + conf + "\n" + "-" * 60)

    async def start_udp_based_server(
        self, host, port
    ) -> mitmproxy_rs.wireguard.WireGuardServer:
        return await mitmproxy_rs.wireguard.start_wireguard_server(
            host,
            port,
            self.server_key,

View on GitHub (pinned to 2ac5b089d9)

When it happens

Trigger: Thrown at mitmproxy/proxy/mode_servers.py:369 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mitmproxy/mitmproxy@2ac5b089d9 (2026-08-26). Data as JSON: /api/errors/41da83f5b79d8251. Report an issue: GitHub.