Vercel - Internal Server Error (500) with no error log

Hello,

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:

  1. I tried with vercel dev (locally). Works flawlessly.
  2. Reverting the project (via git) to a version I knew worked. Still doesn’t work in the online version.
  3. Checked the Serverless function usage, and it’s far below limits (both invocation number and the duration usage)
  4. 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.

Hey @astlaan,

Sorry for the incoming wall of questions! I need more info…

  • What version of Python does the project use?

  • Is the 500 error shown coming from Vercel, like this? If so, please share the error code or a screenshot.

  • If you include a print("some string") at the start of the function, does that appear in the logs for your project?

  • Do you have a public repo or minimal reproducible example the rest of us can use to help you debug?

2 Likes

Hi,

Thank you for the prompt reply.

  1. 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.

  2. This is the screenshot of the error in the Logs:

  1. “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.

  1. The repository is here:
    GitHub - Astlaan/electricity-consumption-mix
1 Like

Hi, any input?
Still need to fix it

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.
1 Like

Hi @anshumanb , thanks for the reply.

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:

def handle_request(request_body):
    print("RUNNING 124")
    return {"statusCode": 200, "body": json.dumps({"plot": "test"})}

This is what I see in the Logs in the Vercel website:

And this is what I see in the web console after clicking on the website button that does the API Call:

Here is the complete code:

It seems the Logs initially report a code 200?

Hi @astlaan, thanks for adding more details about debugging steps.

I tried running this code and it works:

import json
from http.server import BaseHTTPRequestHandler

def handle_request():
    print("RUNNING 124")
    return {"statusCode": 200, "body": json.dumps({"plot": "test"})}

class handler(BaseHTTPRequestHandler):
    
    def do_GET(self):
        response = handle_request()
        self.send_response(response['statusCode'])
        self.send_header('Content-type', 'application/json')
        self.end_headers()
        self.wfile.write(response['body'].encode('utf-8'))
        return

I think there’s some other issue in the code that’s unrelated to Vercel.