# RuntimeError: Event loop is closed

**Code:** `Event loop is closed` · **Category:** Python · **Seen on:** Python

Async code tried to use an event loop that has already been shut down.

## Meaning

Common on Windows with asyncio.run() and aiohttp/httpx clients cleaned up after the loop closes, and when mixing asyncio.run() calls with long-lived clients.

## Common causes

- Client sessions not closed before the loop ends
- Calling asyncio.run() repeatedly with shared resources
- Windows ProactorEventLoop cleanup noise

## Quick fix

1. Use async with for clients/sessions
2. Run everything inside a single asyncio.run(main())
3. On Windows, close clients explicitly before returning

## Detailed fix by platform

### Python

1. 

```python
async with httpx.AsyncClient() as client:
    r = await client.get(url)
```


## How to diagnose

1. **Resource** — Which client is cleaned up late?
2. **Pattern** — Multiple asyncio.run() calls?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/python/asyncio-event-loop-is-closed)
