SupabaseVectorStore connection (FastAPI backend on Render) failing with "OperationalError... Network is unreachable"

I have a Python backend for my LlamaIndex application (using FastAPI + Render) that uses “SupabaseVectorStore” to set up the connection with my Supabase DB. It works 100% fine locally on localhost, but when I host it in Render, I suddenly get this error:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at “db.[USER_HERE]”, port [PORT_NUMBER] failed: Network is unreachable

Is the server running on that host and accepting TCP/IP connections?

The code where the Supabase DB connection is setup is:

import logging
import os

from llama_index.core.indices import VectorStoreIndex
from llama_index.vector_stores.pinecone import PineconeVectorStore
from llama_index.vector_stores.supabase import SupabaseVectorStore
from llama_index.core import StorageContext

logger = logging.getLogger("uvicorn")

def get_index():"Connecting to index from Supabase...")
    vector_store = SupabaseVectorStore(
    storage_context = StorageContext.from_defaults(vector_store=vector_store)
    index = VectorStoreIndex(nodes=[], storage_context=storage_context)"Finished connecting to index from Supabase.")
    return index


SUPABASE_DB_URL = postgresql://postgres:[YOUR-PASSWORD]@db.[USER][PORT]/postgres

FYI, I am using the direct connection (postgresql://) version of the connection string, but also have tried connection pooling (postgres://) - with no success. All community docs on Render point me to use “postgresql://”.

Anyone have any idea how to fix this? I’ve been grappling with this for HOURS and am completely lost… :sob:

Hi Jae,

On the Render side, for troubleshooting purposes, you could try logging your Postgres connection string to make sure it’s what you expect (you might want to change your password after doing this).

Otherwise, I would check on your Supabase instance to ensure there are no access controls you need to set up (i.e. IP address allow lists, etc.).