Django Cockroach ORM Connection refused

Like the title says our django app can’t seem to connect to our cluster
perhaps someone could point us in the right direction?

i already wrote support but i guess it can’t hurt to post it here again

What is your situation?

I am unable to connect to my cluster I have setup via docker swarm by following and using the official guides in a production environment, but I am successful in a “insecure” testing/ dev environment.

We have, for this instance, no firewall active or really anything else than a standard install: nginx and even the cockroach cluster overview can be accessed via:

I have tried various database connection configurations including the official ones with no success including the ones below with and without the commented out parts
which in my mind should work.

Including that I have also tried to follow: Build a Python App with CockroachDB and Django | CockroachDB Docs
which lead me to the same problem.

The main error messages I am getting when either trying to run the app or make migrations are, in order:


psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host “” and accepting
TCP/IP connections on port 26257?

django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host “” and accepting
TCP/IP connections on port 26257?


Our git repository can be found on gitlab: Balu / calorietracker · GitLab (branch cockroach)

Debian 10
Docker - latest as of writing this (20)
Django ORM : django-cockroachdb · PyPI
guide which was followed : Orchestrate CockroachDB with Docker Swarm | CockroachDB Docs
Hosting Provider: Vultr

-Tell us about your CockroachDB cluster

3 nodes in 3 different european datacenters (germany,france,netherlands)
data and replication factor is irrelevant at this point as we can not connect to it at all but we are planing on having less than a few G of data striped across every node

When/how would you consider this issue resolved?

When we can connect via a django ORM to our cluster

Hi! Sorry you haven’t had an answer on this for a while. Are you still having this problem?

It sounds like your setup has a lot of components, so hard to pin down where exactly the problem might be. The first thing is to isolate what is different between your production environment versus dev environment. For example, do both environments use nginx? I wonder if the proxy might have an issue with forwarding the traffic from your app to the DB cluster?

Are you able to modify your Django app to try to connect directly to one of the production nodes (as a test).