1

I am using Next.js with Vercel PostgreSQL. I have connected my project to Vercel PostgreSQL. It works fine in production but I encounter errors in development.

Previously, I was facing issues while testing locally. However, after deploying it, the project is functioning properly in production without any problems. Unfortunately, I am still facing errors during local development, which are depicted in the attached images. Please note that I have imported the environment variables into the local setup and linked the project properly.I've tried installing node_modules again as well.
enter image description here

enter image description here

6
  • Can you confirm that you can connect to the database server using the credentials that you used locally, from another client on your local machine? I'm also curious what is above the line on your error screenshot. Commented Apr 9, 2024 at 10:47
  • Which client i can use to test locally? Commented Apr 9, 2024 at 10:58
  • See wiki.postgresql.org/wiki/PostgreSQL_Clients. Personally I have good experience with HeidiSQL on Windows. Commented Apr 9, 2024 at 11:19
  • I used a vs code extension and yes i can access my db tables here using same cred. Commented Apr 9, 2024 at 15:09
  • Can you show more of your error log? From the current log there is no indication of why the fetch failed. Commented Apr 9, 2024 at 15:43

1 Answer 1

0

I'd suggest checking the following:

  1. PostgreSQL String Credentials: Make sure that the string credentials for connecting to your PostgreSQL database are set up correctly, both in your local setup and on your production deployment.

  2. Node.js Version Compatibility: Check if your Node.js version aligns with your project requirements. It seems that the issue may stem from discrepancies in Node.js versions.

It seems that the problem lies with the Node.js version. I would suggest utilizing a version manager like "n" (n – Interactively Manage Your Node.js Versions) to manage your Node.js versions efficiently.

npm i n

You can shift to Node.js version 19, which is compatible with most dependencies and frameworks like next.js. Please retest your project locally to confirm if the issue persists.

If you encounter any further issues or require additional assistance, please don't hesitate to ask.

Sign up to request clarification or add additional context in comments.

2 Comments

Nowadays would recommend Volta, not n or nvm, because it autodetects the right node version based on the folder that you're in.
Thank you so much. It helped me, the issue was i was using node version 20. I downgraded it to 19 and it worked as expected. I noticed vercel deployment is also using node version 18. Thanks Karar Shah

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.