Connection types
Memgraph Lab enables you to connect to a running Memgraph instance with:
- Quick connect - Allows you to quickly connect to a running Memgraph instance on
localhost:7687
. - Manual connect - Starting from Lab 2.16, Memgraph Lab supports three types of connections to your Memgraph instances:
Connect to a standalone instance
A standalone connection is a standard Bolt connection to a single Memgraph instance. This option is commonly used in the following scenarios:
-
You’re running Memgraph, but not with the default settings or the Quick Connect feature isn’t working. If you’re unsure why Quick Connect isn’t functioning, please refer to the Troubleshoot connection issues section.
-
You have multi-tenancy enabled in Memgraph and want to connect to a specific database.
-
You want to connect to a coordinator instance that manages the cluster state in a high availability cluster.
You will need to define:
- Host: Either
localhost
,127.0.0.1
,0.0.0.0
, or another appropriate address. - Port: Enter
7687
, which Memgraph uses by default. - Logs port: Default is
7444
, the port for web socket logs. - Database name: Leave empty unless connecting to a multi-tenant Memgraph instance.
- Encrypted: Choose whether the connection is
encrypted (
SSL on
orSSL off
).
Once you’ve successfully connected to Memgraph, you will see the following:
In case you can’t connect, please refer to the Troubleshoot connection issues section.
Coordinator instance
Standalone connections can also be used to connect to a Coordinator instance. When connecting to the Coordinator, the Lab UI changes to support only cluster management queries. You will see components like query execution, run history, query collections and query sharing. The status bar will display the number of active and total coordinators and data instances instead of the number of nodes, relationships and memory/disk metrics.
Connect to a main or replica instance
Connecting to a main or replica instance is similar to connecting to a standalone instance with an additional status bar difference upon successful connection: Replication status overview.
If connected to a main instance, the status bar will display replication status, including the status of replicas and their system and data replication status. The status bar will also show that you are connected to the “Main” instance.
If connected to a replica, you will not see the replication status because replicas do not have the permission to display this information. The status bar will show that you are connected to the “Replica” instance.
Connect to an HA cluster with automatic failover
High availability is an enterprise feature that supports automatic failover with a set of coordinators and data instances.
To connect to the High availability cluster, choose the “HA Cluster” connection type and input the Host and Port of any coordinator instance (typical Memgraph’s high available cluster consists of three coordinator instances).
When connected to the HA cluster, you can run queries and manage data similar to a standalone or main/replica instance connection. Additionally, the status bar provides information about the cluster status, showing the status of each coordinator and data instance.
Connection color
You can customize the connection color to help visually distinguish between different environments.
The selected color will appear below the status bar, making it easier to tell connections apart when working with multiple Memgraph instances in the same Lab session.
Troubleshoot connection issues
Memgraph Lab detects if Memgraph is running on localhost:7687
by default for
the Quick Connect. The environment variables that are responsible for Quick
Connect working as expected are:
QUICK_CONNECT_MG_HOST
: specifies the hostname or IP addressQUICK_CONNECT_MG_PORT
: specifies the port number, e.g.- e QUICK_CONNECT_MG_PORT=7688
QUICK_CONNECT_MG_IS_ENCRYPTED
: indicates whether the connection should be encrypted
The handling of the QUICK_CONNECT_MG_HOST
environment variable differs based
on the operating system:
-
Mac or Windows: The
host.docker.internal
hostname allows Docker containers to connect to the host machine. Set this as the value forQUICK_CONNECT_MG_HOST
when running Lab on Mac or Windows to enable connection to Memgraph running on the host:docker run -d -p 3000:3000 -e QUICK_CONNECT_MG_HOST=host.docker.internal --name lab memgraph/lab
-
Linux: There’s no need to set
QUICK_CONNECT_MG_HOST
as it defaults tolocalhost
, assuming Memgraph is running locally on the host machine.
If you didn’t set QUICK_CONNECT_MG_HOST
with Docker in advance or if you’re
running a desktop version of Memgraph Lab, you can create a new connection and
specify host.docker.internal
as the Host.