Client doesn't work when QDrant behind reverse proxy
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.
I'm also facing same issue but using python client.
@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" )
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.
@craig-matadeen : you are a life saver! This is literally crazy!
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
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, });
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, });
Thanks @nikolas-sturm, yes setting the port as per your example works.
@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
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
:443in the url does not do anything at least in my case. usingexport 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
portparam 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
This cost me 4 hours or so. The current implementation should be changed to just support URL strings.