Setting up pgvector postgresql db
uzochiapa
PROOP

3 months ago

I have an issue, when I create a db using the pgvector extension, I don't see a database tab like I would see in a regular database template.

I am tryting to create a database that has pgvector extension

Attachments

Solved$10 Bounty

Pinned Solution

bytekeim
PRO

3 months ago

no problem, let's try get you connected

for pgAdmin get your connection details from Railway's service variables:

  • host: Your service's public domain or RAILWAY_PRIVATE_DOMAIN

  • port: 5432

  • database: postgres

  • username: postgres

  • pswd: Check your POSTGRES_PASSWORD variable (you might need to set this if you haven't)

and in pgAdmin, create a new server and plug in those details make sure you're using the public domain if connecting from outside railway

for vscode : use the postgresql extension and your connection string should look like:

postgresql://postgres:YOUR_PASSWORD@YOUR_HOST:5432/postgres

make sure your service has a public domain exposed (check railway settings), and double-check your password is set in the environment variables , If it's timing out, the port might not be exposed publicly

if this didn't work for you, can you share what error message you're getting when trying to connect

10 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


3 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 3 months ago


uzochiapa
PROOP

3 months ago

So can you explain why I can't see the database tab when I create a template that has the postgresql and pgvector18 template? I looked at the BOT and I can't seem to find an answer to my issue


uzochiapa
PROOP

3 months ago

if I change the source to pgvector/pgvector:pg17

would it affect the database and how do I enable pgvector this way?

it would be nice if I can just add vector extension to an existing db


bytekeim
PRO

3 months ago

Hey! the pgvector templates work fine, they just don't show Railway's database UI tab because they're Docker containers, not managed databases.

to fix this just use the pgvector-pg18 template you deployed. Connect to it with the connection details from your service variables, then run this sql:

CREATE EXTENSION IF NOT EXISTS vector;

The database works exactly the same - you just manage it through regular PostgreSQL tools (psql, pgAdmin, etc.) instead of Railway's UI. That's normal for these templates.

don't switch your existing postgres-ssl:17 image to a pgvector image, you'll lose all your data. If you need pgvector on that existing database, connect to it first and try running CREATE EXTENSION vector; to see if it's already available. If not, you'll need to start fresh with a pgvector template.


bytekeim

Hey! the pgvector templates work fine, they just don't show Railway's database UI tab because they're Docker containers, not managed databases.to fix this just use the pgvector-pg18 template you deployed. Connect to it with the connection details from your service variables, then run this sql:CREATE EXTENSION IF NOT EXISTS vector;The database works exactly the same - you just manage it through regular PostgreSQL tools (psql, pgAdmin, etc.) instead of Railway's UI. That's normal for these templates.don't switch your existing postgres-ssl:17 image to a pgvector image, you'll lose all your data. If you need pgvector on that existing database, connect to it first and try running CREATE EXTENSION vector; to see if it's already available. If not, you'll need to start fresh with a pgvector template.

uzochiapa
PROOP

3 months ago

Thank you for the information. I created a PostgreSQL db using the pgvector-pg18 template, but now I am having issues connecting to pgAdmin or even using VSCode.


bytekeim

Hey! the pgvector templates work fine, they just don't show Railway's database UI tab because they're Docker containers, not managed databases.to fix this just use the pgvector-pg18 template you deployed. Connect to it with the connection details from your service variables, then run this sql:CREATE EXTENSION IF NOT EXISTS vector;The database works exactly the same - you just manage it through regular PostgreSQL tools (psql, pgAdmin, etc.) instead of Railway's UI. That's normal for these templates.don't switch your existing postgres-ssl:17 image to a pgvector image, you'll lose all your data. If you need pgvector on that existing database, connect to it first and try running CREATE EXTENSION vector; to see if it's already available. If not, you'll need to start fresh with a pgvector template.

3 months ago

Small correction: We don't offer managed databases at all, everything is a container.


brody

Small correction: We don't offer managed databases at all, everything is a container.

bytekeim
PRO

3 months ago

thanks for the clarification! yeah, everything's containerized on railway, my bad on the wording :))


uzochiapa

Thank you for the information. I created a PostgreSQL db using the pgvector-pg18 template, but now I am having issues connecting to pgAdmin or even using VSCode.

bytekeim
PRO

3 months ago

no problem, let's try get you connected

for pgAdmin get your connection details from Railway's service variables:

  • host: Your service's public domain or RAILWAY_PRIVATE_DOMAIN

  • port: 5432

  • database: postgres

  • username: postgres

  • pswd: Check your POSTGRES_PASSWORD variable (you might need to set this if you haven't)

and in pgAdmin, create a new server and plug in those details make sure you're using the public domain if connecting from outside railway

for vscode : use the postgresql extension and your connection string should look like:

postgresql://postgres:YOUR_PASSWORD@YOUR_HOST:5432/postgres

make sure your service has a public domain exposed (check railway settings), and double-check your password is set in the environment variables , If it's timing out, the port might not be exposed publicly

if this didn't work for you, can you share what error message you're getting when trying to connect


uzochiapa
PROOP

3 months ago

Thank you bytekeim. The only change I made was the port. I used a different port that was in the public networking tab. 5432 wasn't working at first. After the connection was established, I was able to create an extension vector using this command
CREATE EXTENSION IF NOT EXISTS vector; CREATE TABLE items (id serial PRIMARY KEY, embedding vector(1536));


bytekeim
PRO

3 months ago

awesome! glad you got it working; you're all set to start storing embeddings now :))


Status changed to Solved uxuz 3 months ago


Loading...