[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [Help](/c/help/9) # NextJS Flask API. A Serverless Function Exceeding 250MB Limit 182 views · 1 like · 5 posts SemireOS (@damic995) · 2025-07-08 · ♥ 1 I am working on a Next.js project with a Python Flask API that I'm deploying to Vercel. My deployments are consistently failing with the error: `Error: A Serverless Function has exceeded the unzipped maximum size of 250 MB.` I believe this indicates that one or more of my Python serverless functions (API routes) is exceeding Vercel's unzipped size limit. * **Current Behavior:** The Vercel build finishes collecting page data, but then fails during the "Deploying outputs" phase with the `unzipped maximum size of 250 MB` error. I cannot currently identify *which specific function* is causing this, or what is contributing most to its size. **Troubleshooting Steps & Context** **Local Bundle Size Check Script:** I've implemented a local Node.js script (`scripts/check-bundle-size.js`) that runs `du -sk` (Linux/macOS) or PowerShell's `Get-ChildItem | Measure-Object -Sum` (Windows) on the `.vercel/output/functions` directory after `next build`. * **Problem:** When I run `npm run build` (which executes `next build && node scripts/check-bundle-size.js`), my script reports "No functions directory found. Skipping bundle size check." This indicates that `functions` directory is not yet populated by Vercel during the `next build` phase, so my script is not effective in catching the oversized function during a Vercel cloud build. 3. **Missing Specific Function Name in Logs:** The Vercel build logs, as shown in the snippets below, indicate the general 250MB error, but they **do not specify the name of the function** (e.g., `api_my_specific_function.func`) that is oversized, which makes targeted debugging difficult. **`requirements.txt` (example, likely the source of the bloat):** (I suspect `boto3` and its transitive dependencies might be a significant contributor, but I can't confirm without knowing *which* function is oversized.) `Flask==3.0.3 Flask-Cors==3.0.10 Flask-RESTful==0.3.9 PyJWT==2.10.1 boto3==1.35.90 python-dotenv==1.0.1 1. **How can I get more detailed logs from Vercel that specifically tell me the name and exact unzipped size of the serverless function(s) exceeding the 250 MB limit?** The current general error message is not specific enough for debugging. 2. Once I identify the specific function, what are the most effective strategies to diagnose *which part* of its code or *which specific dependencies* are causing the excessive bundle size? (I know about `du -sh` but need to figure out the root cause for Vercel's packaging). 3. Are there any best practices for Python/Next.js on Vercel to preemptively avoid such large function bundles, especially with common libraries like `boto3`? Any help or guidance would be greatly appreciated! Thanks in advance. Pauline P. Narvas (@pawlean) · 2025-07-17 Hey, @damic995! Have you seen this guide? May be helpful: https://vercel.com/guides/troubleshooting-function-250mb-limit SemireOS (@damic995) · 2025-07-17 Hello Pauline, Thanks for responding. Yes I have seen that guide before and tried everything that applied to me. My issue is that my package.json is unchanged compared to one of my previous deployments that was successful, the and not much changed in my python api folder. I even tried reverting my git commits to the last working deployment and redeploying BUT EVEN THAT DIDN'T WORK. I used npm dedupe to remove duplicates, used all the tools to check my node_modules package dependenices size and they are all irrelevant. I figured it was my python functions that could be causing the issue so I reduced the files to TWO python files and it still was over. This is why I am asking if there is a way to check the individual sizes of serverless functions also in the python environment so I can know where to focus on. Pauline P. Narvas (@pawlean) · 2025-07-24 Vercel has a **250MB limit** for serverless functions, so your Flask app is probably too big. You can: * Remove or replace heavy Python libraries * Exclude big files in `next.config.js` * Split the app into smaller API routes Feel free to follow this thread for information on how to get good answers. If you can, feel free to share a minimal reproducible example for us to take a look at. https://community.vercel.com/t/how-to-get-good-answers/158 Pauline P. Narvas (@pawlean) · 2026-02-25 Sharing some good news here — Vercel has increased the Python Functions bundle size limit from **250MB to 500MB** (unzipped). Your Next.js + Flask deployment was failing during the "Deploying outputs" phase because of this limit, so the extra headroom should let it go through. Give it another deploy and let us know how it goes! Reference: https://vercel.com/changelog/python-vercel-functions-bundle-size-limit-increased-to-500mb