0

I've had a problem with Nuxt3 for some time, or more precisely with Nitro built into it. I'm using the experimental "database" option and I'm using mysql2 as a connector. The problem is that after some time of inactivity on the site, it disconnects the connection to the database and the only thing I have in the logs is this: [nuxt] [request error] [unhandled] [500] Can't add new command when connection is in closed state

This is what my nuxt.config.ts file looks like:

import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default defineNuxtConfig({
 css: [
 '@/assets/css/custom-scrollbar.css'
 ],
 ssr: true,
 app: {
 baseURL: "/",
 },
 compatibilityDate: "2024年11月01日",
 devtools: { enabled: true },
 modules: [
 "@nuxtjs/tailwindcss",
 "nuxt-auth-utils",
 "@nuxt/image",
 "@nuxt/icon"
 ],
 nitro: {
 experimental: {
 database: true
 },
 database: {
 default: {
 connector: 'mysql2',
 options: {
 database: process.env.NUXT_MYSQL_DATABASE_NAME,
 user: process.env.NUXT_MYSQL_USER,
 password: process.env.NUXT_MYSQL_PASSWORD,
 host: process.env.NUXT_MYSQL_HOST,
 port: process.env.NUXT_MYSQL_PORT,
 waitForConnections: true,
 connectionLimit: 10,
 queueLimit: 0,
 enableKeepAlive: true,
 }
 }
 },
 storage: {
 db: {
 driver: 'fs',
 base: resolve(__dirname, '.cache/db')
 }
 }
 }
});
Shadow
34.5k10 gold badges67 silver badges76 bronze badges
asked Feb 14, 2025 at 21:33
1

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.