DEV Community

Cover image for Some Common Vercel Errors
Shafia Rahman Chowdhury
Shafia Rahman Chowdhury

Posted on • Updated on

Some Common Vercel Errors

When deploying your server-side on Vercel, you may face some common errors sometime. In this blog, I will provide solutions to help you resolve these following errors effortlessly.

1) Error

Cannot GET/your_route_name

Solution

Step-1: Remove "await client.connect ()" in the try block of the run function of your index.js file

Step-2: Go to your vercel.json file and change your dest value to index.js like the one below:

{
   "version": 2,
   "builds": [
       {
           "src": "./index.js",
           "use": "@vercel/node"
       }
   ],
   "routes": [
       {
           "src": "/(.*)",
           "dest": "index.js"
       }
   ]
}
Enter fullscreen mode Exit fullscreen mode

Step-3: Then, run these command on your terminal

vercel
vercel --prod
Enter fullscreen mode Exit fullscreen mode

2) Error

This Serverless Function has crashed

Image description

This error have few possible solutions

Solution - 1

Step-1: Remove "await client. connect ()" in the try block of the run function of your index.js file

Step-2: Then, run these command on your terminal

vercel
Vercel --prod
Enter fullscreen mode Exit fullscreen mode

Solution - 2

Step-1: Go to your index.js file, remove app.use(cors()) and write this code instead:

const corsConfig = {
    origin: '',
    credentials: true,
    methods: ['GET', 'POST', 'PUT', 'DELETE']
}
app.use(cors(corsConfig))
app.options("", cors(corsConfig))
Enter fullscreen mode Exit fullscreen mode

Step-2: Then, go to your vercel.json file and copy-paste this code:


{
    "version": 2,
    "builds": [
        {
            "src": "./index.js",
            "use": "@vercel/node"
        }
    ],
    "routes": [
        {
            "src": "/(.*)",
            "dest": "/",
            "methods": ["GET", "POST", "PATCH", "DELETE", "OPTIONS"]
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Step - 3: Then, run these command on your terminal

vercel
Vercel --prod
Enter fullscreen mode Exit fullscreen mode

_If you still see the error change dest value to "dest": "index.js" and deploy the server again using the step-3 command.

Solution-3

Check if you have added your environment variables in your Vercel

Go to Vercel dashboard --> Choose the project --> settings--> Environment Variables

Make sure the enviroment variables you added match with the one in your .env file

Solution-4

If any of the above solutions don’t work, then run this command on your terminal

vercel logs your_production_url
Enter fullscreen mode Exit fullscreen mode

Vercel will let you know if there is any errors in your index.js file.

3) Error

bad credentials Vercel sign up

Step-1: Run this command on your terminal to uninstall Vercel

npm uninstall -g vercel
Enter fullscreen mode Exit fullscreen mode

Step-2: Re-install Vercel globally

npm i -g vercel
Enter fullscreen mode Exit fullscreen mode

Step-3: Now login using the command below:

vercel login
Enter fullscreen mode Exit fullscreen mode

4) Error

This Serverless function has timed out

Visit this blog to resolve this issue:

https://dev.to/shafia/the-errors-you-may-face-for-not-whitelisting-the-ip-address-0000-in-your-mongodb-network-access-32f8

5) Error

Fix vercel error : A system error occurred: uv_os_gethostname returned ENOSYS (function not implemented)

If you are using Windows 7, you may face this error

Solution:

Step-1: Go to Users -->your_computer_name folder –>
node_modules->vercel->dist->index.js

Step-2: On the top write,

const os=require("os")
os.hostname=()=>"localhost"
Enter fullscreen mode Exit fullscreen mode

Lastly, if you don’t know how to deploy your server using Vercel CLI, follow this blog

https://medium.com/@shafiarahmanchy13/how-to-deploy-a-node-express-server-using-vercel-cli-f0a464d4e88c

For each error, I have provided step-by-step solutions to help you resolve them effectively.

By following the steps outlined in this blog, you can troubleshoot and overcome these errors.

Happy deploying!

Top comments (8)

Collapse
 
md-mehedi-hasan-nabil profile image
Md. Mehedi Hasan Nabil

Thank You so much.❤️

Collapse
 
syedashiqbd profile image
Syed Ashiq

Thanks for the valuable information about vercel Error, it will help a lot for newbies.

Collapse
 
a4arpon profile image
Shahin Islam

Thanks for sharing this apu. Naile assignment e error khaite khaite ses hoia jaitasi.

Collapse
 
shatab99 profile image
MD Shahriar Shatab

thank you miss ❤

Collapse
 
abid365 profile image
Syed Jawad Bin Azam

Works like a charm, I wonder why people are so lazy to read articles. The solution is given here and without noticing it people are rushing for s.session. Kudos to you

Collapse
 
developer-shourav profile image
Shourav Raj

Thank You so much sister. It's saved me

Collapse
 
tezalve profile image
T.M. Estiaq Zaman

the serverless function has crashed problem is fixed by removing app.use(cors) using the given the code. but the server-side gives the error "blocked by cors policy". any solutions?

Collapse
 
shafia profile image
Shafia Rahman Chowdhury

{
"version": 2,
"builds": [
{
"src": "./index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/",
"methods": ["GET", "POST", "PATCH", "DELETE", "OPTIONS"]
}
]
}
copy-paste this code in your vercel.json and redeploy your site on vercel