This error occurs when your Prisma Accelerate project exceeds the included query limit on your current pricing plan. It only occurs on the free tier when you hit the 60,000 monthly queries limit.
The P5008 error indicates that your Prisma Accelerate project has exhausted the included usage for your current billing plan. This error can only occur when using Prisma Accelerate on the free tier. The free tier of Prisma Accelerate includes 60,000 database queries per month. Once you exceed this limit, Prisma pauses access to your database to prevent unexpected charges. This is a protective billing mechanism that gives you control over your costs. It's important to note that queries are counted at the Prisma Client invocation level. A single Prisma query that translates into multiple SQL statements under the hood still counts as just one query. Additionally, cached queries also count toward your usage limit—even if a query is served from the cache, it contributes to your monthly quota.
First, confirm your project is on the free tier:
1. Log in to [Prisma Data Platform](https://console.prisma.io)
2. Navigate to your workspace
3. Go to Billing → Pricing Plans
4. Check your current plan—if it says "Free," you have hit the limit
You can also check your current usage:
1. Go to Workspace Settings → Usage & Billing
2. View your "Queries" section
3. If it shows "60,000 / 60,000," you have exceeded the limit
The error P5008 only occurs on the free plan. Paid plans have higher limits and will not pause access when limits are approached.
The quickest solution is to upgrade to a paid plan:
1. Go to Workspace Settings → Billing → Pricing Plans
2. Select your desired tier:
- Starter: 10 million queries/month (pay-as-you-go pricing)
- Pro: 50 million queries/month
- Business: Custom limits
3. Choose your payment method and confirm
4. Your project will immediately resume access
After upgrading, your database will be accessible again within seconds. Paid plans offer:
- Higher query limits
- Cost controls with spend alerts at 75% of your limit
- No service interruption when usage increases
- Per-query rate pricing instead of monthly tiers
If you prefer not to upgrade immediately:
1. Your quota resets automatically at the beginning of next month
2. Database access will resume when the monthly reset occurs (usually UTC midnight on the 1st)
3. You can continue using Prisma Accelerate on the free tier next month
Important: This approach means your application will be unable to access the database for the remainder of the current billing month. Plan accordingly if your application needs continuous availability.
You will receive notifications from Prisma before your project pauses, giving you time to upgrade if needed.
While waiting for the next billing cycle or preparing for upgrade, implement query optimization to reduce future usage:
Use field selection (select):
// Before: Fetches all fields
const users = await prisma.user.findMany();
// After: Only fetch needed fields
const users = await prisma.user.findMany({
select: { id: true, email: true, name: true }
});Implement pagination:
// Before: Could fetch 10,000+ records in one query
const allUsers = await prisma.user.findMany();
// After: Fetch 100 at a time
const users = await prisma.user.findMany({
take: 100,
skip: 0,
orderBy: { id: 'asc' }
});Cache frequently accessed data:
// Use Redis, Memcached, or application-level caching
const cachedUser = await redis.get(`user:${id}`);
if (!cachedUser) {
const user = await prisma.user.findUnique({ where: { id } });
await redis.setex(`user:${id}`, 3600, JSON.stringify(user));
}These optimizations reduce the number of database queries, lowering your monthly usage.
Understand where your queries are coming from:
Enable Prisma query logging:
const prisma = new PrismaClient({
log: [
{ emit: 'event', level: 'query' },
{ emit: 'stdout', level: 'error' },
],
});
prisma.$on('query', (e) => {
console.log('Query: ' + e.query);
console.log('Duration: ' + e.duration + 'ms');
});Use Prisma Studio to review your schema:
npx prisma studioCheck for problematic patterns:
- N+1 queries: Fetching parent records, then fetching related records one-by-one
- Unnecessary queries in loops
- Missing indexes on frequently queried fields
- Unoptimized relationship loading
Once you identify high-traffic areas, optimize them first.
After upgrading, configure alerts to prevent hitting limits unexpectedly:
1. Go to Workspace Settings → Billing
2. Look for "Usage Alerts" or "Spending Limits"
3. Set your monthly spending limit (paid plans allow this)
4. Enable email notifications at 75% of your limit
Prisma will send you an alert when you reach 75% of your configured limit, giving you time to either:
- Upgrade to a higher tier
- Optimize queries to reduce usage
- Plan for expected high-traffic periods
For production applications, it's recommended to always have a paid plan with generous limits to ensure uninterrupted service.
Understanding Accelerate Quotas: The free tier limit is shared across your entire project. Every query—whether from your production app, development environment, or Prisma Studio—counts toward the 60,000 monthly quota. If you're running multiple environments (dev, staging, production) against the same Accelerate project, consider using separate connection strings or projects for non-production environments.
Query Counting Details: Prisma counts queries at the client invocation level, not at the SQL statement level. This means if one Prisma query translates to 5 SQL statements (due to joins, relation loading, etc.), it still counts as 1 query. However, this also means cached queries count. If you execute the same query 100 times and it hits the cache 99 times, all 100 count toward your quota.
Migration Path: If you consistently exceed the free tier, calculate which paid tier makes sense:
- Starter plan: 10M queries/month (pay-as-you-go)
- Pro plan: 50M queries/month (fixed price + overage)
- Business plan: Custom pricing
At high volumes, per-query costs on Accelerate's pay-as-you-go model are very affordable (typically under $0.0001 per query).
Development Environment Strategy: To avoid consuming free-tier quota on development databases, consider:
1. Running a local PostgreSQL instance for local development
2. Using a separate Prisma project/workspace for non-production environments
3. Implementing local caching for frequent queries in development
4. Using database snapshots or seeded databases to minimize queries during testing
Comparison with Direct Database Access: Accelerate queries count separately from direct database connections. If you bypass Accelerate and connect directly to your database, those queries won't count toward the Accelerate quota. However, you lose Accelerate's caching and connection pooling benefits.
P1013: The provided database string is invalid
The provided database string is invalid
P1000: Authentication failed against database server
Authentication failed against database server
P1010: User was denied access on the database
How to fix "P1010: User was denied access on the database" in Prisma
P3021: Foreign keys cannot be created on this database
How to fix 'P3021: Foreign keys cannot be created on this database' in Prisma
Value out of range for the type
How to fix 'P2020: Value out of range for the type' in Prisma