2 months ago
Hey, I'm having trouble connecting it the latest image (1.4.0) using the Typescript client. Here's my setup.
On the client side, I'm doing:
const chromaClient = new ChromaClient({
ssl: false,
host: 'chroma.railway.internal',
port: 8000,
});
On the service, I have the private network URL set to chroma.railway.internal , volume mounted to /data and the following environment variables:
CHROMA_HOST_ADDR="::"CHROMA_PRIVATE_URL="http://${{RAILWAY_PRIVATE_DOMAIN}}:${{CHROMA_HOST_PORT}}"CHROMA_PUBLIC_URL="https://${{RAILWAY_PUBLIC_DOMAIN}}"CHROMA_HOST_PORT="8000"
The client is always throwing Error querying data: ChromaConnectionError: Failed to connect to chromadb
I've tried @brody's suggestion, but I get uvicorn not found . Probably that doesn't apply anymore since the answer is from 2 years ago.
Pretty sure the problem is related with the private network connection and IPV6, because I can access the instance using public networking.
Can you help me?
9 Replies
2 months ago
Hey, thank you for reaching out
I deployed the template and couldn't replicate the error unfortunately. Can you make sure:
your ChromaDB deployment has a private network endpoint which is
chroma.railway.internalas specified in your code?your ChromaDB deployment has
PORT="8000"as well, I notice a few service variables missing / modified thereyour ChromaDB deployment is running
Also, quick side note, I noticed you modified the CHROMA_PRIVATE_URL variable, that variable is actually used by the auth proxy and if modified the auth proxy might not work as expected. If you're not using the auth proxy and do not plan on using it then this is fine though.
Attachments
Status changed to Awaiting User Response Railway • 2 months ago
2 months ago
Thanks for the quick reply!
I've deleted and added a new instance of Chroma, but the client error persists. Here's what I have:
On the client,CHROMA_URL="${{Chroma.CHROMA_PRIVATE_URL}}:${{Chroma.CHROMA_HOST_PORT}}", which is http://chroma.railway.internal:8000
On the Chroma image, the following variables set (default ones):
CHROMA_HOST_ADDR="::"
CHROMA_HOST_PORT="${{PORT}}"
CHROMA_PRIVATE_URL="http://${{RAILWAY_PRIVATE_DOMAIN}}", which is http://chroma.railway.internal
CHROMA_PUBLIC_URL="https://${{RAILWAY_PUBLIC_DOMAIN}}", which is https://
CHROMA_TIMEOUT_KEEP_ALIVE="30"
CHROMA_WORKERS="1"
IS_PERSISTENT="True"
PORT="8000"
Sending screenshots attached. My chroma deployment has a private network address of chroma.railway.internal
Should I have a different port?
Status changed to Awaiting Template Creator Response Railway • 2 months ago
2 months ago
Port 8000 is perfect, just wanted to make sure you had that in there
I must admit, I am very confused. I'm noticing you're making changes to the base template - I tried following those changes (like migrating chromadb to 1.4.0), updated my testing environment's chroma client, introduced service configuration variations, and I'm still not able to reproduce your error. That is at the very least within the scope of the tests I run.
Could you check:
When you deploy the template, before making any changes (like moving to 1.4.0), are you still seeing connection errors? (meaning, try deploying a clean chroma from the template making zero changes and see if you're still getting errors)
If so, can you share the actual exact code you're using to connect to the database? (unless what you shared above is the actual exact code)
When exactly are you getting that error, is it upon chroma client creation or after a specific action?
I notice your first 2 deployments fail, how is that possible? what errors are you getting?
Sorry for the unproductive back and fourth, I'm passionate about Chroma and I'm genuinely trying my best to reproduce this error 😔
Status changed to Awaiting User Response Railway • 2 months ago
2 months ago
Hey, appreciate your help!
Just deployed the template fresh: version 1.3.0, no changed variables.
I am using an application to connect to Chroma, but I just tried with a Railway function to do a sanity check. You can find the code below, and the error I get attached.
I'm getting the error when I try to perform an action: AFAIK the client creation doesn't actually try to connect, it just connects upon an action.
Client code:
// index.tsx (Bun v1.3 runtime)
import { Hono } from "hono@4";
import { cors } from "hono/cors";
import { ChromaClient } from "chromadb";
const app = new Hono();
app.use("/*", cors());
app.get("/", (c) => c.text("Hello world!"));
app.get("/api/health", (c) => c.json({ status: "ok" }));
app.get("/api/chroma", async (c) => {
const client = new ChromaClient({
ssl: false,
host: "chroma.railway.internal", // Or your service's private domain
port: 8000,
// No authentication needed on private network
});
const heartbeat = await client.heartbeat();
console.log("Heartbeat:", heartbeat);
// Example: Create a collection and add embeddings
const collection = await client.createCollection({
name: "my_collection",
embeddingFunction: undefined, // Provide embeddings manually
});
console.log("Collection:", collection.id);
await collection.add({
ids: ["id1", "id2"],
embeddings: [
[1.2, 2.3, 4.5],
[6.7, 8.9, 1.2],
],
metadatas: [{ source: "doc1" }, { source: "doc2" }],
documents: ["This is document 1", "This is document 2"],
});
console.log("Addded to collection!");
return c.json({ status: "ok" });
});
Bun.serve({
port: import.meta.env.PORT ?? 3000,
fetch: app.fetch,
});
Attachments
Status changed to Awaiting Template Creator Response Railway • 2 months ago
2 months ago
Hey,
We are looking into an issue that affects IPv4 private networking on a small subset of hosts.
Status changed to Awaiting User Response brody • 2 months ago
2 months ago
I'm still getting errors, even trying to access from the public endpoint.
I'm using the default configuration from the template, nothing changed. Sending screenshot of the logs attached.
Below is my function code. The env variables are:
CHROMA_TOKEN="${{\"Auth Proxy\".API_KEY}}"
CHROMA_PUB_URL="https://${{\"Auth Proxy\".RAILWAY_PUBLIC_DOMAIN}}"
CHROMA_PRIV_URL="${{Chroma.CHROMA_PRIVATE_URL}}:${{Chroma.CHROMA_HOST_PORT}}"
These translate to:
CHROMA_TOKEN="***"
CHROMA_PUB_URL="https://auth-proxy-production-dff0.up.railway.app"
CHROMA_PRIV_URL="http://chroma.railway.internal:8000"
Code:// index.tsx (Bun v1.3 runtime)
import { Hono } from "hono@4";
import { cors } from "hono/cors";
import { ChromaClient } from "chromadb";
const app = new Hono();
async function performActionOnClient(client: ChromaClient) {
const heartbeat = await client.heartbeat();
console.log("Heartbeat:", heartbeat);
// Example: Create a collection and add embeddings
const collection = await client.createCollection({
name: "my_collection",
embeddingFunction: undefined, // Provide embeddings manually
});
console.log("Collection:", collection.id);
await collection.add({
ids: ["id1", "id2"],
embeddings: [
[1.2, 2.3, 4.5],
[6.7, 8.9, 1.2],
],
metadatas: [{ source: "doc1" }, { source: "doc2" }],
documents: ["This is document 1", "This is document 2"],
});
console.log("Addded to collection!");
}
app.use("/*", cors());
app.get("/", (c) => c.text("Hello world!"));
app.get("/api/health", (c) => c.json({ status: "ok" }));
app.get("/api/chroma/public", async (c) => {
const chromaUrl = new URL(process.env.CHROMA_PUB_URL);
const chromaToken = process.env.CHROMA_TOKEN;
const options = {
ssl: chromaUrl.protocol === "https:",
host: chromaUrl.hostname,
port: parseInt(
chromaUrl.port || (chromaUrl.protocol === "https:" ? "443" : "80")
),
headers: {
Authorization: Bearer ${chromaToken},
},
};
console.log("Creating public client with options:", options);
const client = new ChromaClient(options);
await performActionOnClient(client);
return c.json({ status: "ok" });
});
app.get("/api/chroma/private", async (c) => {
const chromaUrl = new URL(process.env.CHROMA_PRIV_URL);
const options = {
ssl: chromaUrl.protocol === "https:",
host: chromaUrl.hostname,
port: Number(chromaUrl.port),
};
console.log("Creating private client with options:", options);
const client = new ChromaClient(options);
await performActionOnClient(client);
return c.json({ status: "ok" });
});
Bun.serve({
port: import.meta.env.PORT ?? 3000,
fetch: app.fetch,
});
Attachments
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
Update:
I've created a new project. Deployed the Chroma template with all default configuration (didn't change anything), and a Railway function with the code identical to the one above that connects to the Chroma instance. It worked!
Then I deleted what I had from Chroma on my existing project, and deployed the template. Again, with all default configuration. Added a function with the same code. It doesn't work!
This is very weird behavior. The only reason I see is that there is something on my existing project that makes it fail. I'm considering moving everything to the new project and hopefully it works. But it looks like a problem on Railway side.
Any comments on this?
2 months ago
Hello,
There are no networking issues on our side at the moment; any issues would be due to a misconfiguration.