I have a Nodejs project which contains some serverless functions within api/ and its working fine. I also have a Python script that I would like to include in my project as a python serverless funciton. I've tried a few things and they didn't work so, I went through a few other help threads and have tried their suggestions but so far the suggestions haven't worked for me.
I can explain what I've tried and show the settings for my files but before doing that I want to know if this is true:
Is it really impossible to be able to have a Python serverless function alongside NodeJs serverless functions within /api? Can't we just configure which runtime to use for a specific serverless function? My project isn't using any framework, just Typescript and Python.
If there is a way to have Python and NodeJs serverless functions within the same project please let me know so I can share more details.
Vercel Staff
Hi , thanks for asking this question.
To clarify, you can keep Python and Node.js serverless functions in the same project. The question that you linked was about using Python script inside a Node.js function, which is not supported because each function has a dedicated runtime.
This is a project that I've which has both Python and Node.js functions
Thank you for the response and I apologize for misreading the other help thread.
I deployed a project that contains Node & Python serverless functions to Vercel and both endpoints work. However, when developing locally using the Vercel CLI I keep getting, this huge error:
at Server.<anonymous> (file:///C:/Users/o0/.bun/install/global/node_modules/@vercel/node/dist/dev-server.mjs:1133:12)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Command failed: taskkill /pid 1808 /T /F
ERROR: The process "1808" not found.
at ChildProcess.exithandler (node:child_process:422:12)
at ChildProcess.emit (node:events:517:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:303:5)
Error: An unexpected error occurred!
Error: Command failed: taskkill /pid 1808 /T /F
ERROR: The process "1808" not found.
at ChildProcess.exithandler (node:child_process:422:12)
at ChildProcess.emit (node:events:517:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:303:5)
and when accessing http://localhost:8071/api/python
vercel dev --listen 8071
Vercel CLI 41.2.2
> Ready! Available at http://localhost:8071
> Building @vercel/python@latest:api/main_flow.py
Installing required dependencies...
> Built @vercel/python@latest:api/main_flow.py [3s]
AssignProcessToJobObject: (87) The parameter is incorrect.
LambdaError: RequestId: a3e98b22-7754-4aa4-aa3b-c7966447871f Process exited before completing request
at Lambda.<anonymous> (C:\Users\o0\.bun\install\global
ode_modules\@vercel\fun\dist\src\index.js:114:27)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\o0\.bun\install\global
ode_modules\@vercel\fun\dist\src\index.js:28:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
using HTTP Handler
Traceback (most recent call last):
File "C:\Python311\Lib\urllib\request.py", line 1348, in do_open
File "C:\Python311\Lib\urllib\request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>
I changed up the ports because I thought it might have to do with ports being in use. Long errors, I just wanted to share but maybe I'm just tired since its late here, I'll take a look at these tomorrow and update.
Note: I installed the Vercel CLI using Bun, I don't know if that might be the issue.
Vercel Staff
Hi , are you able to start these individual files using node and python directly?
If you need more help, please share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.
I can access the api/node and api/python but when I am running it locally, I can only access api/node and when I try to access api/python I get the following error:
404: NOT_FOUND
Code: NOT_FOUND
ID: dev1::m0dro-1740772524199-12ed8c11ac38
Hmm, I just tried deploying the hello-world Python template and that is also erroring when I run it locally but works when hosted on Vercel, accesed via *.vercel.app url.
But the error is different, when I go to http://localhost:3000/api it shows
502: BAD_GATEWAY
Code: NO_RESPONSE_FROM_FUNCTION
ID: dev1::dev1::11jq7-1740773958622-87294de9dd2d
Check the logs in your terminal window to see the application error.
in the terminal:
vercel dev
Vercel CLI 41.2.2
? Set up and develop “~\source\developer\projects\mine\vanilla\python-hello-world”? yes
? Which scope should contain your project? nazcodeland's projects
? Found project “nazcodelands-projects-bac6b4e1/python-hello-world”. Link to it? yes
🔗 Linked to nazcodelands-projects-bac6b4e1/python-hello-world (created .vercel and added it to .gitignore)
> Ready! Available at http://localhost:3000
> Building @vercel/python@latest:api/index.py
Installing required dependencies...
> Built @vercel/python@latest:api/index.py [5s]
AssignProcessToJobObject: (87) The parameter is incorrect.
LambdaError: RequestId: e2793808-9871-48fe-81b5-62fae5e3df19 Process exited before completing request
at Lambda.<anonymous> (C:\Users\o0\.bun\install\global
ode_modules\@vercel\fun\dist\src\index.js:114:27)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\o0\.bun\install\global
ode_modules\@vercel\fun\dist\src\index.js:28:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
using HTTP Handler
Traceback (most recent call last):
File "C:\Python311\Lib\urllib\request.py", line 1348, in do_open
File "C:\Python311\Lib\http\client.py", line 1037, in _send_output
self.send(msg)
File "C:\Python311\Lib\http\client.py", line 975, in send
self.connect()
File "C:\Python311\Lib\http\client.py", line 941, in connect
self.sock = self._create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\socket.py", line 850, in create_connection
raise exceptions[0]
File "C:\Python311\Lib\socket.py", line 835, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\o0\AppData\Local\com.vercel.fun\Cache\runtimes\python\bootstrap.py", line 147, in <module>
lambda_runtime_main()
at least with this it tried to build and install dependencies,
> Building @vercel/python@latest:api/index.py
Installing required dependencies...
> Built @vercel/python@latest:api/index.py [5s]
...
whereas in the template I made using vercel inithttps://github.com/NazCodeland/vite-vercel it doesn't even try to build/install when I try to access the api/python locally.