I’ve started experience issues with a site I have hosted, where I am using python serverless functions.
Up till recently, everything was fine. However, now I am getting a 500 - Internal Server Error in Vercel logs, but I get no proper error log. All that I get in the log output is:
127.0.0.1 - - [05/Mar/2025 16:42:18] "POST /api/generate_plot HTTP/1.1" 200 -
16:42:18.902
[async_get_physical_flows] Start: 16:42:18, End: 16:42:18, took 0.26s: from: 10YPT-REN------W to 10YES-REE------0
16:42:18.921
[async_get_physical_flows] Start: 16:42:18, End: 16:42:18, took 0.28s: from: 10YFR-RTE------C to 10YES-REE------0
16:42:18.957
[async_get_physical_flows] Start: 16:42:18, End: 16:42:18, took 0.31s: from: 10YES-REE------0 to 10YFR-RTE------C
16:42:18.960
[async_get_physical_flows] Start: 16:42:18, End: 16:42:18, took 0.32s: from: 10YES-REE------0 to 10YPT-REN------W
16:42:19.181
[async_get_generation_data] Start: 16:42:18, End: 16:42:19, took 0.55s: country: 10YPT-REN------W
16:42:19.220
[async_get_generation_data] Start: 16:42:18, End: 16:42:19, took 0.58s: country: 10YFR-RTE------C
16:42:19.262
[async_get_generation_data] Start: 16:42:18, End: 16:42:19, took 0.62s: country: 10YES-REE------0
16:42:19.264
[get_data] total duration: 0.6280560493469238s
16:42:22.340
127.0.0.1 - - [05/Mar/2025 16:42:22] "POST /api/generate_plot HTTP/1.1" 200 -
i.e., no error whatsoever. Here’s what I tried:
I tried with vercel dev (locally). Works flawlessly.
Reverting the project (via git) to a version I knew worked. Still doesn’t work in the online version.
Checked the Serverless function usage, and it’s far below limits (both invocation number and the duration usage)
In my API file in python, I tried changing the error code of my error 500 to something else, and I kept receiving error 500 (in the online version). So it’s not my API that’s emitting the error 500.
So I don’t think it’s on my code’s side, and I don’t think I changed much in my vercel settings.
It’s very frustrating, because it’s an error code without any error log that can guide my debug, so I have absolutely no idea how to debug this.
Python version: I am not using Pipfile, but rather requirements.txt (if I remember I ended up using this due to some bug with Pipfile). As such, I suppose that, according to Using the Python Runtime with Vercel Functions, vercel is defaulting to python 3.12.
“If you include a print("some string") at the start of the function, does that appear in the logs for your project?”
Yes. That’s how I got the output I pasted in the first post. Also, now I also added a print to the top of the handle_request function in the api call file, and it gets printed also to the output log.
Hi @astlaan, sorry for the delayed response but our team is on a company offsite.
Let me dig into how to debug this together.
I’ve two suggestions for you:
Can you try changing the Node.js version from your project’s Build settings to 22.x?
If that doesn’t help, let’s narrow down the project scope and make that specific endpoint return 200 without any processeing. So, request comes and the first line of code is a 200 response with some message. This way we can narrow down where the issue lies.
I changed the Node.js version in the project build settings to 22.x, but the problem persists.
I tried to narrow down on the error: I made it so that my handle_request function for my API doesn’t no any processing, but rather returns right away after a print: