[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [Help](/c/help/9) # Vercel PHP serverless functions failing to connect to Supabase Postgres 20 views · 1 like · 1 post JorgY_ (@wizkhalifax) · 2026-03-28 · ♥ 1 ## Problem I am building a web application using a modern frontend stack (**Vite, TailwindCSS, Flowbite, and SweetAlert2**) powered by a **PHP backend**. Initially, this project was developed and tested successfully on my local machine using a **Laragon/MySQL** setup. To deploy the application on **Vercel**, I decided to upgrade my database and migrate from MySQL to **Supabase (PostgreSQL)**. While the application and the Supabase connection work perfectly on my local environment, the database connection completely fails after deploying to Vercel, despite the frontend loading successfully. ## Current Behavior - Frontend loads perfectly, but API calls to `/api/beneficiaries.php` return a `500` status. - My DB diagnostic endpoint confirms the following: - `db_connection=pgsql` - `use_supabase=true` - `host`/`port`/`db`/`user`/`password` are all set correctly - `db_sslmode=require` - `pdo_pgsql_loaded=true` Despite this, it still fails with the error: > **Error: Could not connect to database. Please check your configuration.** ## Expected Behavior PHP API functions deployed on Vercel should successfully connect to the Supabase Postgres database and return data, exactly as they do on my local machine. ## Steps to Reproduce 1. Deploy project to Vercel with PHP functions (`vercel-php@0.7.4`) and Vite-built frontend. 2. Set production environment variables: - `DB_CONNECTION=pgsql` - `DB_HOST` - `DB_PORT=5432` - `DB_DATABASE` - `DB_USERNAME` - `DB_PASSWORD` - `DB_SSLMODE=require` - `APP_ENV=production` - `ENV_KEY=production` 3. Open the diagnostic endpoint: `https://dole-system.vercel.app/api/auth.php?db_test=1` 4. The output returned is: ```json { "success": false, "error": "Could not connect to database..." } ``` ## Project Information - **URL:** [https://dole-system.vercel.app](https://dole-system.vercel.app) - **Frontend:** Vite, TailwindCSS, Flowbite, SweetAlert2 - **Backend:** PHP API on Vercel Serverless (`vercel-php@0.7.4`) - **Database:** Supabase Postgres (Direct connection) - **Runtime config confirmed via script:** - `db_connection=pgsql` - `use_supabase=true` - `db_sslmode=require` - `pdo_pgsql_loaded=true` ## Main Question What are the most likely causes when PHP on Vercel reports all DB variables as present and the `pgsql` extension as loaded, but the `PDO` connection still fails to reach Supabase Postgres? Is there any Vercel-specific networking, SSL, or connection-string requirement for connecting to Supabase using PHP serverless functions?