MySQL connection closes after some time with db0 + mysql2
Hey everyone
I’m running a Nuxt 4 app with a connection to a MySQL database using db0 + mysql2.
my nuxt config
db config file
About the issue
Everything works fine at first, but after a few hours/days of inactivity, I get this error in my container logs:
It looks like the database socket gets closed (MySQL wait_timeout / idle), and db0/mysql2 doesn’t recover → I need to restart the container to make it work again.
Someone have any idea or already met that problem ?
Thanks for you're help 🙏
2 Replies
Hi @Pikawshh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources provided do not contain specific information about using db0 with mysql2 in Nuxt 4, nor do they address issues with MySQL connections closing after periods of inactivity or how to handle automatic reconnection in this context.
The sources do cover Nitro's server engine, advanced Nitro configuration, and database adapters supported by Nuxt Content (such as SQLite, D1, Postgres, and LibSQL), but there is no mention of db0, mysql2, or strategies for persistent MySQL connections or handling dropped connections in Nuxt 4 or Nitro. Therefore, I cannot provide a confident, source-based answer to your question about this specific MySQL connection issue.
If you need official guidance, I recommend checking the documentation for db0, mysql2, or opening an issue in the Nuxt or db0 repositories for more targeted support.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@612280800997539881> Kapa.ai is still learning and improving, please let me know how I did by reacting below.