Manage connections
List all network connections
An administrator is able to view all network connections within the database instance. Alternatively, the current user may view all of their own network connections.
The procedure dbms.listConnections
lists all accepted network connections for all configured connectors, including Bolt, HTTP, and HTTPS.
Some listed connections might never perform authentication.
For example, HTTP GET requests to the Neo4j Browser endpoint fetches static resources and does not need to authenticate.
However, connections made using Neo4j Browser require the user to provide credentials and perform authentication.
For more information on Neo4j Browser connections, see the Neo4j Browser documentation.
Syntax:
CALL dbms.listConnections()
Name | Type | Description |
---|---|---|
|
String |
This is the ID of the network connection. |
|
String |
This is the time at which the connection was started. |
|
String |
Name of the connector that accepted the connection. |
|
String |
This is the username of the user who initiated the connection. This field will be null if the transaction was issued using embedded API. It can also be null if connection did not perform authentication. |
|
String |
Name of the software that is connected.
For HTTP and HTTPS connections, this information is extracted from the |
|
String |
The server address this connection is connected to. |
|
String |
The client address of the connection. |
Neo4j client agent | userAgent default string format |
Example |
---|---|---|
Cypher Shell |
|
|
Neo4j Browser |
|
|
Neo4j Bloom |
|
|
Neo4j Java Driver |
|
|
Neo4j .Net Driver |
|
|
Neo4j Go Driver |
|
|
Neo4j Python Driver |
|
|
Neo4j JavaScript Driver |
|
|
The following example shows that the user 'alwood' is connected using Java driver and a Firefox web browser.
The procedure call yields specific information about the connection, namely connectionId
, connectTime
, connector
, username
, userAgent
, and clientAddress
.
CALL dbms.listConnections() YIELD connectionId, connectTime, connector, username, userAgent, clientAddress
╒══════════════╤══════════════════════════╤═══════════╤══════════╤════════════════════════════════════════════════════════════════════════════════════╤═════════════════╤═════════╕ │"connectionId"│"connectTime" │"connector"│"username"│"userAgent" │"clientAddress" │"status" │ ╞══════════════╪══════════════════════════╪═══════════╪══════════╪════════════════════════════════════════════════════════════════════════════════════╪═════════════════╪═════════╡ │"bolt-21" │"2018-10-10T12:11:42.276Z"│"bolt" │"alwood" │"neo4j-java/1.6.3" │"127.0.0.1:53929"│"Running"│ ├──────────────┼──────────────────────────┼───────────┼──────────┼────────────────────────────────────────────────────────────────────────────────────┼─────────────────┼─────────┤ │"http-11" │"2018-10-10T12:37:19.014Z"│"http" │null │"Mozilla/5.0 (Macintosh; Intel macOS 10.13; rv:62.0) Gecko/20100101 Firefox/62.0"│"127.0.0.1:54118"│"Running"│ └──────────────┴──────────────────────────┴───────────┴──────────┴────────────────────────────────────────────────────────────────────────────────────┴─────────────────┴─────────┘ 2 rows
Terminate multiple network connections
An administrator is able to terminate within the instance all network connections with any of the given IDs. Alternatively, the current user may terminate all of their own network connections with any of the given IDs.
Syntax:
CALL dbms.killConnections(connectionIds)
Arguments:
Name | Type | Description |
---|---|---|
|
List<String> |
This is a list of the IDs of all the connections to be terminated. |
Returns:
Name | Type | Description |
---|---|---|
|
String |
This is the ID of the terminated connection. |
|
String |
This is the username of the user who initiated the (now terminated) connection. |
|
String |
A message stating whether the connection was successfully found. |
Considerations:
Bolt connections are stateful. Termination of a Bolt connection results in termination of the ongoing query/transaction. |
Termination of an HTTP/HTTPS connection can terminate the ongoing HTTP/HTTPS request. |
The following example shows that the administrator has terminated the connections with IDs 'bolt-37' and 'https-11', started by the users 'joesmith' and 'annebrown', respectively. The administrator also attempted to terminate the connection with ID 'http-42' which did not exist.
CALL dbms.killConnections(['bolt-37', 'https-11', 'http-42'])
╒══════════════╤═══════════╤══════════════════════════════════╕ │"connectionId"│"username" │"message" │ ╞══════════════╪═══════════╪══════════════════════════════════╡ │"bolt-37" │"joesmith" │"Connection found" │ ├──────────────┼───────────┼──────────────────────────────────┤ │"https-11" │"annebrown"│"Connection found" │ ├──────────────┼───────────┼──────────────────────────────────┤ │"http-42" │"n/a" │"No connection found with this id"│ └──────────────┴───────────┴──────────────────────────────────┘ 3 rows
Terminate a single network connection
An administrator is able to terminate within the instance any network connection with the given ID. Alternatively, the current user may terminate their own network connection with the given ID.
Syntax:
CALL dbms.killConnection(connectionId)
Arguments:
Name | Type | Description |
---|---|---|
|
String |
This is the ID of the connection to be terminated. |
Returns:
Name | Type | Description |
---|---|---|
|
String |
This is the ID of the terminated connection. |
|
String |
This is the username of the user who initiated the (now terminated) connection. |
|
String |
A message stating whether the connection was successfully found. |
Considerations:
Bolt connections are stateful. Termination of a Bolt connection results in termination of the ongoing query/transaction. |
Termination of an HTTP/HTTPS connection can terminate the ongoing HTTP/HTTPS request. |
The following example shows that the user 'joesmith' has terminated his connection with the ID 'bolt-4321'.
CALL dbms.killConnection('bolt-4321')
╒══════════════╤═══════════╤══════════════════╕ │"connectionId"│"username" │"message" │ ╞══════════════╪═══════════╪══════════════════╡ │"bolt-4321" │"joesmith" │"Connection found"│ └──────────────┴───────────┴──────────────────┘ 1 row
The following example shows the output when trying to kill a connection with an ID that does not exist.
CALL dbms.killConnection('bolt-987')
╒══════════════╤═══════════╤══════════════════════════════════╕ │"connectionId"│"username" │"message" │ ╞══════════════╪═══════════╪══════════════════════════════════╡ │"bolt-987" │"n/a" │"No connection found with this id"│ └──────────────┴───────────┴──────────────────────────────────┘ 1 row