Troubleshooting
Common troubles and their solutions.
Find answers to questions other developers have asked - it might be just what you need!
Common Issues
Environment variables from .env are not being loaded
Make sure you are running the npm run dev command from the root directory of your project (where the package.json file is located).
Note
Next.js automatically loads environment variables from .env when running the
development server. Make sure the file exists in the root directory and
contains all required variables.
Also make sure that the environment variable you are trying to access in your application is prefixed with NEXT_PUBLIC_ if you want to use it in client-side code.
Application is very slow in production
The most common reason for a slow application in production is the physical distance between the server or serverless functions and the database.
Make sure to deploy your application to a region that is close to your database. For example when you are using Vercel, you can select the region of the Vercel serverless functions in the project settings under the Functions tab.
Database connection issues
If you're experiencing database connection issues:
- Verify your
DATABASE_URLin.envis correct - Make sure your database is running and accessible
- Check if your database allows connections from your IP address (for managed databases)
- Verify the database credentials are correct
Prisma Client not generated
If you're getting errors about Prisma Client not being found:
- Run
npm run db:migrate:devto generate the Prisma Client and apply migrations - The Prisma client is automatically generated during migrations and in the build process via
postinstallscript
Port already in use
If port 3000 is already in use, you can change it by setting the PORT environment variable:
PORT=3001 npm run dev