diff --git a/reflex/app.py b/reflex/app.py index 081f838424..5f1ef96f5e 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -1211,7 +1211,10 @@ async def on_event(self, sid, data): } # Get the client IP - client_ip = environ["REMOTE_ADDR"] + try: + client_ip = environ["asgi.scope"]["client"][0] + except (KeyError, IndexError): + client_ip = environ.get("REMOTE_ADDR", "0.0.0.0") # Process the events. async for update in process(self.app, event, sid, headers, client_ip):