RuntimeError: Event loop is closed
Async code tried to use an event loop that has already been shut down.
Event loop is closedThis event loop is already runningThere is no current event loop 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
- Use async with for clients/sessions
- Run everything inside a single asyncio.run(main())
- On Windows, close clients explicitly before returning
Detailed fix by platform
Python
- python
async with httpx.AsyncClient() as client: r = await client.get(url)
How to diagnose
- Resource — Which client is cleaned up late?
- Pattern — Multiple asyncio.run() calls?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- AbortError AbortError: The user aborted a request. / signal is aborted without reason
- async useEffect Warning: useEffect must not return anything besides a function, which is used for clean-up. It looks like you wrote useEffect(async () => ...)
- await outside async SyntaxError: await is only valid in async functions and the top level bodies of modules
Most viewed in Python
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026