Standing up Postgres with pgvector on Forge or your own cluster usually means an apt repo, extension privileges and pinning a version that matches whatever embedding SDK you're running. I've done that dance enough times to dread it. Laravel Cloud's Serverless Postgres collapses the whole setup into a checkbox — pgvector is preinstalled, the cluster autoscales, and compute hibernates when nothing is querying.
Most devs still default to the manual path because they don't know the managed one exists. If you're choosing between platforms first, my Laravel Vapor vs Forge in 2026 walkthrough covers where Cloud lands against the rest. This guide assumes you've picked Cloud and want vector search live in the next fifteen minutes.
Create a Laravel Serverless Postgres cluster#
Open the Laravel Cloud dashboard, pick the project you want the database in, and add a new resource. Choose Serverless Postgres as the cluster type, give it a name, and select the region that matches your application environment. Pick the smallest compute size — autoscaling will move you up if traffic demands it, and hibernation drops you back down when it doesn't. Provisioning takes around thirty seconds.
There's nothing to configure for pgvector at this step. Every Laravel Serverless Postgres cluster is built on Neon and ships with the extension already compiled into the image. You just have to enable it inside your database, which we'll do in a migration further down.
Attach the database to your environment#
A cluster on its own does nothing for your app — Laravel Cloud needs to know which environment owns it. Open the environment's resources panel and attach the cluster you just created. The dashboard will surface the connection details, but you don't need to copy them anywhere. As soon as the database is attached, Cloud queues an environment variable injection for the next deploy.
If you have multiple environments (staging, production, preview), attach a separate cluster to each unless you have a deliberate reason to share. Hibernation is per-cluster, and a shared cluster means staging traffic keeps production warm — which silently kills the cost benefit.
Re-deploy to inject the connection variables#
This is the step that catches almost everyone the first time. The injected variables only land on the next deploy — attaching the cluster does not hot-swap them into a running container. Trigger a deploy from the dashboard or push a commit to your tracked branch.
After the deploy completes, your environment will have these set:
DB_CONNECTION=pgsql
DB_HOST=ep-frosty-shadow-a57j6ubb-pooler.us-east-2.pg.laravel.cloud
DB_PORT=5432
DB_USERNAME=neondb_owner
DB_PASSWORD=<auto-generated>
DB_DATABASE=neondb
Note the -pooler suffix on the host — that's the pgbouncer endpoint, which Laravel Cloud uses by default and which scales to 10,000 concurrent connections. Don't strip it.
Enable the pgvector extension via migration#
pgvector is compiled into the cluster, but it isn't enabled in your database until you CREATE EXTENSION. Generate a fresh migration and run the statement directly:
php artisan make:migration enable_pgvector_extension
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
DB::statement('CREATE EXTENSION IF NOT EXISTS vector');
}
public function down(): void
{
DB::statement('DROP EXTENSION IF EXISTS vector');
}
};
Deploy. Cloud runs php artisan migrate --force as part of the deploy pipeline and the extension is live. You don't need a superuser role — the neondb_owner user that Cloud provisions has the privilege built in, which is the part that always trips you up on a self-managed cluster.
Add a vector column and run a sanity query#
With the extension enabled, the rest is normal Laravel. Add a vector(1536) column to whichever model you want to embed — 1536 matches OpenAI's text-embedding-3-small. Adjust the dimensionality if you're using a different model.
php artisan make:migration add_embedding_to_documents_table
public function up(): void
{
Schema::table('documents', function (Blueprint $table) {
$table->vector('embedding', 1536)->nullable();
});
}
Cast the column to array on the Eloquent model so embeddings round-trip cleanly:
protected function casts(): array
{
return [
'embedding' => 'array',
];
}
Sanity-check it with a quick tinker call. If you've got the AI SDK wired up, whereVectorSimilarTo() from Laravel 13 handles embedding the query string for you:
php artisan tinker --execute 'Document::whereVectorSimilarTo("embedding", "onboarding checklist")->limit(5)->get();'
If that returns rows, the stack works. From here it's the same pattern as any pgvector workload — backfill embeddings in a queued job, rebuild on update, and add an HNSW index once you cross a few thousand rows. The full RAG pattern, including chunking and the queued backfill, is in my Laravel AI SDK + pgvector RAG pipeline guide.
Plan for hibernation cold-starts#
Hibernation is the headline feature and the one trade-off worth understanding before you ship. A cluster that hasn't received a query for the configured idle window pauses its compute — you pay for storage but not CPU. The next query wakes it within a few hundred milliseconds. For an internal AI search tool or a low-volume RAG endpoint that's a non-issue. For a public homepage that hits the database on every request, that wake-up will land in your p99 latency.
Two practical rules. First, set the hibernation idle window longer than your traffic gaps — if you get a query every two minutes, a one-minute window is wasted. Second, disable hibernation entirely on production clusters once traffic is steady; the savings are marginal and the cold-start variance is not. The setting lives under the cluster's settings panel.
If hibernation isn't a fit and you'd rather control the runtime yourself, the Dockerising Laravel for Kubernetes walkthrough covers a self-managed alternative — you'll lose the auto-pgvector convenience but gain full control over compute scheduling.
Backups, by the way, are handled automatically. Cloud takes a continuous physical backup with point-in-time restore on the seven days prior — there's nothing for you to schedule or rotate.
Wrapping Up#
Five steps, fifteen minutes, no extension wrangling. The combination of pgvector preinstalled and hibernation on idle compute is what makes Cloud the easiest path to "AI search in production" for a Laravel app today.
If this is your first vector workload, my Laravel AI SDK complete guide covers the embedding side end-to-end. If you'd rather build the agent on top of Prism, Getting started with Laravel Prism is the next step.
FAQ#
Does Laravel Cloud support pgvector out of the box?
Yes. Every Laravel Cloud Serverless Postgres cluster ships with pgvector compiled into the image. You don't need to install or upgrade anything — you only need to run CREATE EXTENSION IF NOT EXISTS vector once via a migration to enable it inside your database.
How do I attach a serverless Postgres database in Laravel Cloud?
Inside the Cloud dashboard, open the environment you want the database attached to and add the cluster as a resource. As soon as it's attached, Cloud queues an environment-variable injection for the next deploy. Trigger a fresh deploy and the connection details land automatically.
What is hibernation for Laravel Serverless Postgres?
Hibernation is the cluster pausing its compute after a configurable idle window with no incoming queries. While hibernating, you don't pay for compute resources — only storage. The cluster wakes within a few hundred milliseconds when the next query arrives, which is fast enough for AI search workloads but visible on a public hot-path request.
How does Laravel Cloud Postgres compare to Neon?
Laravel Cloud Serverless Postgres is built on Neon under the hood, so the autoscaling, hibernation and pgvector behaviour are identical. The difference is the integration: Cloud handles the environment variable injection, the deploy migration step, and pgbouncer pooling without any wiring on your part. If you'd otherwise stand up Neon and a Forge box separately, this is the consolidated version.
Can I run vector search workloads on Laravel Cloud?
Yes — that's the headline use case. Combine the cluster's preinstalled pgvector extension with Laravel 13's whereVectorSimilarTo() query builder method and you have a fully managed semantic search stack. For higher row counts, add an HNSW index to your vector column and the autoscaler will lift compute as queries demand.
Are backups handled automatically on Laravel Cloud Serverless Postgres?
Yes. Cloud takes continuous physical backups with point-in-time restore over the seven days prior to the current moment. There's nothing to schedule, rotate or pay for separately. You can trigger a restore to a new branch from the dashboard if you need to roll back a bad migration or recover deleted rows.