qdrant-js icon indicating copy to clipboard operation
qdrant-js copied to clipboard

Client doesn't work when QDrant behind reverse proxy

Open james-potter opened this issue 10 months ago • 6 comments

The client can't connect when QDrant behind a NGINX reverse proxy.

Dashboard and curl connections to qdrant work when behind reverse proxy. @qdrant/js-client-rest can't connect when QDrant behind reverse proxy.

const { QdrantClient } = require("@qdrant/js-client-rest");
const dotenv = require("dotenv");
dotenv.config();

async function testQdrant() {
    try {
        const qdrant = new QdrantClient({
            url: process.env.QDRANT_URL, // e.g., "http://your-qdrant-server:6333"
            apiKey: process.env.QDRANT_API_KEY,  // Optional, if authentication is needed
            checkCompatibility: false
        });
        const collections = await qdrant.getCollections();
        console.log("Collections:", collections);
    } catch (error) {
        console.error("Error fetching collections:", error);
    }
}

testQdrant();

when connecting directly to QDrant though firewall it work without problem using either http or https when connecting via reverse proxy it times out.

james-potter avatar Mar 06 '25 13:03 james-potter

I'm also facing same issue but using python client.

shahad-dl avatar Mar 24 '25 17:03 shahad-dl

@james-potter @shahad-dl maybe you guys can try implicitly adding the port to the reverse proxy url. So for example, if your instance is behind https://qdrant.example.com, then when you're trying to use the url in the following example,

Instead of

client = QdrantClient( url="https://qdrant.example.com" )

which doesn't work, but the following does (in python):

client = QdrantClient( url="https://qdrant.example.com:443" )

craig-matadeen avatar Apr 01 '25 10:04 craig-matadeen

Thanks for that, although it still doesn't work what I have managed to get to work is using just plain http via the proxy without any upgrading to https at proxy level and that works.

Also just created some other plain scripts without the module querying the API using request, https and fetch and they all work connecting to the https port and getting the collections.

james-potter avatar Apr 01 '25 11:04 james-potter

@craig-matadeen : you are a life saver! This is literally crazy!

dsculptor avatar May 02 '25 12:05 dsculptor

Ok i think i found what the main issue is. I modified the package to make the private props public and log them after creating the client. Having :443 in the url does not do anything at least in my case. using export const qdrant = new QdrantClient({ url: QDRANT_URL, apiKey: QDRANT_API_KEY });:

2025-05-08T15:46:25.636Z INFO : QDRANT_URL: https://<fqdn>:443
2025-05-08T15:46:25.636Z INFO : _https: true
2025-05-08T15:46:25.636Z INFO : _scheme: https
2025-05-08T15:46:25.637Z INFO : _port: 6333
2025-05-08T15:46:25.637Z INFO : _prefix: 
2025-05-08T15:46:25.638Z INFO : _host: qdrant-dev.cryptorii.com
2025-05-08T15:46:25.638Z INFO : _restUri: https://qdrant-dev.cryptorii.com:6333
<times out...>

using export const qdrant = new QdrantClient({ url: QDRANT_URL, apiKey: QDRANT_API_KEY, port: 443 });:

2025-05-08T15:47:41.047Z INFO : QDRANT_URL: https://<fqdn>
2025-05-08T15:47:41.047Z INFO : _https: true
2025-05-08T15:47:41.048Z INFO : _scheme: https
2025-05-08T15:47:41.048Z INFO : _port: 443
2025-05-08T15:47:41.049Z INFO : _prefix: 
2025-05-08T15:47:41.049Z INFO : _host: qdrant-dev.cryptorii.com
2025-05-08T15:47:41.050Z INFO : _restUri: https://qdrant-dev.cryptorii.com:443
2025-05-08T15:47:41.132Z INFO : Qdrant Version Info: {"title":"qdrant - vector search engine","version":"1.14.0","commit":"3617a0111fc8590c4adcc6e88882b63ca4dda9e7"}

I think it would be good to add the port param to the readme and examples, because i honestly only found out about it after going through the source code. Curious if this solves it for your case as well @james-potter

nikolas-sturm avatar May 08 '25 15:05 nikolas-sturm

i had the same issue. I had trouble connecting to a Qdrant instance behind a reverse proxy (ngix, caddy). What finally fixed it for me was explicitly specifying the port in the QdrantClient initialization. ( port=443) Here's the snippet that worked:

python:

import os import logging from qdrant_client import QdrantClient from qdrant_client.http import models

def init_qdrant_client():

try:
    qdrant_url = os.getenv("QDRANT_URL") 
    qdrant_api_key = os.getenv("QDRANT_API_KEY")
    collection_name = os.getenv("QDRANT_COLLECTION", "main")
    
    client = QdrantClient(
        url=qdrant_url,
        api_key=qdrant_api_key,
        port=443,
        prefer_grpc=False 
    )

ts

import { QdrantClient } from "@qdrant/js-client-rest";

const qdrantUrl = process.env.QDRANT_URL; const qdrantApiKey = process.env.QDRANT_API_KEY;

if (!qdrantUrl) { throw new Error("QDRANT_URL qdrant url not set"); }

export const qdrantClient = new QdrantClient({ url: qdrantUrl, apiKey: qdrantApiKey, port: 443, });

Matti181 avatar May 12 '25 20:05 Matti181

Setting port: 443 in @qdrant/js-client-rest worked. I really appreciate it—I had spent a few hours on this.

i had the same issue. I had trouble connecting to a Qdrant instance behind a reverse proxy (ngix, caddy). What finally fixed it for me was explicitly specifying the port in the QdrantClient initialization. ( port=443) Here's the snippet that worked:

python:

import os import logging from qdrant_client import QdrantClient from qdrant_client.http import models

def init_qdrant_client():

try:
    qdrant_url = os.getenv("QDRANT_URL") 
    qdrant_api_key = os.getenv("QDRANT_API_KEY")
    collection_name = os.getenv("QDRANT_COLLECTION", "main")
    
    client = QdrantClient(
        url=qdrant_url,
        api_key=qdrant_api_key,
        port=443,
        prefer_grpc=False 
    )

ts

import { QdrantClient } from "@qdrant/js-client-rest";

const qdrantUrl = process.env.QDRANT_URL; const qdrantApiKey = process.env.QDRANT_API_KEY;

if (!qdrantUrl) { throw new Error("QDRANT_URL qdrant url not set"); }

export const qdrantClient = new QdrantClient({ url: qdrantUrl, apiKey: qdrantApiKey, port: 443, });

The-1818 avatar May 18 '25 08:05 The-1818

Thanks @nikolas-sturm, yes setting the port as per your example works.

james-potter avatar May 18 '25 09:05 james-potter

@james-potter @shahad-dl maybe you guys can try implicitly adding the port to the reverse proxy url. So for example, if your instance is behind https://qdrant.example.com, then when you're trying to use the url in the following example,

Instead of

client = QdrantClient( url="https://qdrant.example.com" )

which doesn't work, but the following does (in python):

client = QdrantClient( url="https://qdrant.example.com:443" )

This works like a charm. Thank you so much

1nnamdi avatar Jul 23 '25 08:07 1nnamdi

Ok i think i found what the main issue is. I modified the package to make the private props public and log them after creating the client. Having :443 in the url does not do anything at least in my case. using export const qdrant = new QdrantClient({ url: QDRANT_URL, apiKey: QDRANT_API_KEY });:

2025-05-08T15:46:25.636Z INFO : QDRANT_URL: https://<fqdn>:443
2025-05-08T15:46:25.636Z INFO : _https: true
2025-05-08T15:46:25.636Z INFO : _scheme: https
2025-05-08T15:46:25.637Z INFO : _port: 6333
2025-05-08T15:46:25.637Z INFO : _prefix: 
2025-05-08T15:46:25.638Z INFO : _host: qdrant-dev.cryptorii.com
2025-05-08T15:46:25.638Z INFO : _restUri: https://qdrant-dev.cryptorii.com:6333
<times out...>

using export const qdrant = new QdrantClient({ url: QDRANT_URL, apiKey: QDRANT_API_KEY, port: 443 });:

2025-05-08T15:47:41.047Z INFO : QDRANT_URL: https://<fqdn>
2025-05-08T15:47:41.047Z INFO : _https: true
2025-05-08T15:47:41.048Z INFO : _scheme: https
2025-05-08T15:47:41.048Z INFO : _port: 443
2025-05-08T15:47:41.049Z INFO : _prefix: 
2025-05-08T15:47:41.049Z INFO : _host: qdrant-dev.cryptorii.com
2025-05-08T15:47:41.050Z INFO : _restUri: https://qdrant-dev.cryptorii.com:443
2025-05-08T15:47:41.132Z INFO : Qdrant Version Info: {"title":"qdrant - vector search engine","version":"1.14.0","commit":"3617a0111fc8590c4adcc6e88882b63ca4dda9e7"}

I think it would be good to add the port param to the readme and examples, because i honestly only found out about it after going through the source code. Curious if this solves it for your case as well @james-potter

This works for me

balaji-g42 avatar Oct 12 '25 08:10 balaji-g42

This cost me 4 hours or so. The current implementation should be changed to just support URL strings.

levino avatar Nov 12 '25 20:11 levino