Skip to main content
Blnk Cloud requires a running Blnk Core instance to work. You can host your own Core instance or deploy a managed Core instance from Blnk. For self-hosted instances, Blnk uses a Query Agent to establish a connection between your Core instance and Blnk Cloud.
The Query Agent is packaged in a docker container that you run on your machine or infrastructure.
Using Core v0.12.0 or lower? To improve speed and performance for your connection, read the optimization guide below.
Using the Query Agent, you get:
  • Enhanced security: No need to expose database credentials or configure complex firewall rules.
  • Read-only access: Agent only requires SELECT permissions, ensuring data integrity.
  • Simplified setup: No need to configure network settings or firewall rules.
  • Reliable connection: Automatic reconnection and health monitoring.

Connect your self-hosted Core

1

Create an instance on Cloud

  1. In your Blnk Cloud workspace, go to Settings → Instances;
  2. Click Deploy an instance;
  3. You’ll see the instance creation form.
Settings → Instances page showing the Deploy an instance button

Go to Settings → Instances and click Deploy an instance

2

Provide instance details

Fill in your instance information:
  1. Instance name: Choose a descriptive name (e.g., “Production”, “Staging”). This is the only required field;
  2. Core URL: Your Blnk Core instance URL (e.g., https://api.yourcompany.com):
    • Make sure it is publicly accessible on the internet. If locally hosted, use a tunnel service like ngrok: ngrok http 5001 to create a public URL.
    • If hosted on a private network, make sure to whitelist our IP addresses so that Cloud can communicate with your ledger:
      • 161.35.166.95
      • 161.35.171.250
  3. Core secret key: Your Blnk Core API secret key set in your blnk.json configuration file. You can leave this empty if you don’t have a secret key.
Instance creation form with instance name, Core URL, and secret key fields

Fill in your instance name, Core URL, and Core secret key, then create the connection

We use your Core URL and secret key to process actions in your workspace. Without them, your instance will be limited to read-only access.
Once done, submit the form.
3

Set up the Query Agent

Copy the Docker command from your Query Agent setup page and run it where it can reach your Core database.
  1. Go to Settings → Instances.
  2. Open the instance actions list or the instance details panel, then click View setup details.
  3. Copy the Docker command from the Query Agent setup page. It already includes your connection key.
  4. Replace <YOUR_DATABASE_URL> with your PostgreSQL connection string from blnk.json.
Opening View setup details and copying the Docker command from the Query Agent setup page

Open View setup details and copy the Docker command from the Query Agent setup page

Make sure to set the correct sslmode for your database. The database connection will fail without it.
If you’re running Blnk locally in Docker using the default blnk.json, see how to connect to your instance in Docker.
4

Verify connection

When the Query Agent is running, your instance shows Connected. Click the instance from your homepage, or go to Settings → Instances and click it, to open the details panel.
Instance details panel showing instance details

Click an instance from the homepage or Settings → Instances to open its details panel


Connecting to your database running inside your Docker container

To connect to your database running inside your Docker container:
1

Check the network of the postgres container

First, you need to identify which Docker network your database container is running on.
This command will show you the network name that your PostgreSQL container is using.
2

Run the Query Agent on the same network

Next, run the Query Agent container on the same network as your database container.
Make sure to replace:
  • <network-name> with the network name from the previous step, e.g. --network blnk_default.
  • Update the DB_URL with your actual database connection details. You can find it in your default blnk.json configuration file.
  • Important: Since you’re running the Query Agent in the same network as your Core docker image, keep postgres as the host in your connection string. This is the service name of your PostgreSQL container.
  • Replace sk_live_... with your actual connection key from the connection setup page on Cloud.

Edit your instance

Go to Settings → Instances, open the instance actions list, and click Edit instance. You can change the name, Core URL, or Core secret key.
1

Core URL

Make sure the Core URL is publicly accessible on the internet. If locally hosted, use a tunnel service like ngrok: ngrok http 5001 to create a public URL.
Edit instance form showing Core URL and secret key fields

Open the actions list, click Edit instance, and update the Core URL or secret key

If hosted on a private network, whitelist Cloud IPs so Cloud can reach your ledger.
2

Core secret key

The Core secret key is created and set by you in your Blnk configuration. Provide the secret key used in your config. If not set, leave empty.

Managing your query agent

1

View the setup guide

Open the instance actions list or the instance details panel and click View setup details. You’ll see your connection details, agent connection key, and connection status.
Query Agent setup guide page showing connection details, agent key, and Connected status

Open View setup details to see your connection key, setup steps, and connection status

2

Monitor connection health

To see how your connection is doing:
bash
The agent listens on port 9090 by default. To change the internal HTTP port, set the HTTP_PORT environment variable.
3

View logs and resource usage

bash
4

Update the Query Agent

To upgrade the Query Agent to the latest version:
bash
If you previously customized the agent’s HTTP port, remember to include -e HTTP_PORT=<port> and publish the same container port with -p <host-port>:<port> when restarting.
5

Stop the Query Agent

To terminate your Query Agent:
bash

Delete an instance

Open the actions list and click Delete instance. Follow the instructions in the modal to complete the action.
This action is irreversible.
Deleting a self-hosted instance from the actions menu with the confirmation modal

Open the actions list and click Delete instance


Performance optimization for Core 0.12.1 or lower

If you’re running Blnk Core version 0.12.1 or lower, you need to apply database indexes to significantly improve query performance and speed up your Blnk Cloud workspace.
If you’re on later versions, these indexes are automatically included and you don’t need to take any action.
1

Connect to your PostgreSQL database

Connect to your Core database using your preferred PostgreSQL client or command line:
bash
2

Apply the database indexes

Run the following SQL commands to create the required indexes:
The indexes will be created and applied to your database. This may take a few moments depending on your database size.
3

Deploy components in the same region

To see faster improvements across Core and Cloud, follow these regional deployment recommendations:
  1. Keep Core and the PostgreSQL database (and other services) in the same region: Deploy your Core instance, PostgreSQL database, and any other related services within the same geographical region to minimize latency.
  2. Keep the Query Agent in the same region as the database: Ensure your Query Agent is deployed in the same region as your PostgreSQL database to reduce query latency and improve connection speed.
4

Verify the improvements

After applying the indexes, refresh your Blnk Cloud workspace to experience improved performance when loading balances, transactions, and other data.

FAQs

  • If you’re running PostgreSQL inside Docker (on a Mac/Linux), use host.docker.internal as the host in your database URL.
  • For Windows, run the Query Agent container on the same network as your database container. Learn more
  • If you’re running PostgreSQL directly on your machine, use localhost as the host in your database URL.
  • Ensure PostgreSQL is running and accessible.
  • Check that the port (default: 5432) is correct.
  • Verify your database credentials are correct.
  • Verify the database URL format is correct.
  • Ensure the database host is accessible from your Docker host.
  • Check that the database user has proper read permissions.
  • Verify network connectivity allows database connections.
  • Ensure SSL mode is correctly configured.
  • Verify Docker is running: docker --version
  • Check if port conflicts exist: docker ps
  • Ensure environment variables are properly formatted.
  • Review Docker logs: docker logs blnk-agent --tail 50
  • Verify the instance URL is accessible and responding.
  • Verify the instance secret key is correctly copied.
  • Ensure SSL certificate is valid if using HTTPS.
  • Confirm the instance is running and accepting connections.
  • Test instance connectivity: curl -H "Authorization: Bearer YOUR_SECRET_KEY" https://your-instance-url/health

Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool. To ask questions or discuss issues, please contact us or join our Discord community.