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()

Table 1. Data retrieved from a database
Name Type Description

connectionId

String

This is the ID of the network connection.

connectTime

String

This is the time at which the connection was started.

connector

String

Name of the connector that accepted the connection.

username

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.

userAgent

String

Name of the software that is connected. For HTTP and HTTPS connections, this information is extracted from the User-Agent request header. For Bolt connections, the user agent is available natively and is supplied in an initialization message.

serverAddress

String

The server address this connection is connected to.

clientAddress

String

The client address of the connection.

Table 2. Default userAgent string formats
Neo4j client agent userAgent default string format Example

Cypher Shell

"neo4j-cypher-shell/v${version}"

"neo4j-cypher-shell/v4.3.0"

Neo4j Browser

"neo4j-browser/v${version}"

"neo4j-browser/v4.3.0"

Neo4j Bloom

"neo4j-bloom/v${version}"

"neo4j-bloom/v1.7.0"

Neo4j Java Driver

"neo4j-java/x.y.z"

"neo4j-java/1.6.3"

Neo4j .Net Driver

"neo4j-dotnet/x.y"

"neo4j-dotnet/4.3"

Neo4j Go Driver

"Go Driver/x.y"

"Go Driver/4.3"

Neo4j Python Driver

"neo4j-python/x.y Python/x.y.z-a-b (<operating-system>)"

"neo4j-python/4.3 Python/3.7.6 (Linux)"

Neo4j JavaScript Driver

"neo4j-javascript/x.y.z"

"neo4j-javascript/4.3.0"

Example 1. List all network connections

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

ids

List<String>

This is a list of the IDs of all the connections to be terminated.

Returns:

Name Type Description

connectionId

String

This is the ID of the terminated connection.

username

String

This is the username of the user who initiated the (now terminated) connection.

message

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.

Example 2. Terminate multiple network connections

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

id

String

This is the ID of the connection to be terminated.

Returns:

Name Type Description

connectionId

String

This is the ID of the terminated connection.

username

String

This is the username of the user who initiated the (now terminated) connection.

message

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.

Example 3. Terminate a single network connection

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