Overview
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. 
- 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: Eliminates network configuration complexity.
- Reliable connection: Automatic reconnection and health monitoring.
Connect your self-hosted Core
1
Create an instance on Cloud
- In your Blnk Cloud workspace, go to Settings > Instances;
- Click Connect new instance;
- You’ll see the instance creation form.

2
Provide instance details
Fill in your instance information:
- Instance name: Choose a descriptive name (e.g., “Production”, “Staging”). This is the only required field;
- 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 5001to 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
 
 
- Make sure it is publicly accessible on the internet. If locally hosted, use a tunnel service like ngrok: 
- Core secret key: Your Blnk Core API secret key set in your blnk.jsonconfiguration file. You can leave this empty if you don’t have a secret key.

 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. 
3
Set up the Query Agent
Next, you run the following docker command in your terminal to set up your Query Agent.
bash
- 
To get your CONNECTION_KEY:- Go to Settings > Instances and view your instance details.
- Copy your Connection key from your instance info.
  
- Replace the placeholder database URL with your actual connection string.
4
Verify connection
Return to your Blnk Cloud workspace:
- Check connection status: Navigate back to Settings > Instances;
- Verify agent status: Your instance should show as “Connected” with a green indicator.

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. Replace the placeholders with your actual values.Make sure to replace:
- <network-name>with the network name from the previous step.
- <container-name>with your preferred container name.
- Update the DB_URLwith your actual database connection details. You can find it in your defaultblnk.jsonconfiguration file.
- Replace sk_live_...with your actual connection key from the connection setup page on Cloud.
Managing your query agent
Monitor connection health
To see how your connection is doing:bash
Update the Query Agent
To upgrade the Query Agent to the latest version:bash
Stop the Query Agent
To terminate your Query Agent:bash
FAQs
Trouble connecting to your database locally?
Trouble connecting to your database locally?
- If you’re running PostgreSQL inside Docker (on a Mac/Linux), use host.docker.internalas 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 localhostas 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.
Database connection failed?
Database connection failed?
- 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.
Docker container won't start
Docker container won't start
- 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
Instance authentication failed
Instance authentication failed
- 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