Skip to content

Failure Connecting to AWS Neptune Gremlin Endpoint

0

Hi,

We are attempting to create data in AWS Neptune using Gremlin, but we are encountering the following error during execution :

Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.

Could you please review the attached logs and error stack trace and advise whether any configuration changes, network settings, or other corrective actions are required to resolve this issue?

AWSNeptuneSchemaCreation Trying  to get traversal from neptune 
AWSNeptuneSchemaCreation SSL is enabled
AWSNeptuneSchemaCreation IAM Authentication is enabled
AWSNeptuneSchemaCreation ### maxInProcessPerConnection : 20
AWSNeptuneSchemaCreation ### maxSimultaneousUsagePerConnection : 16
AWSNeptuneSchemaCreation ### maxConnectionPoolSize : 20
AWSNeptuneSchemaCreation ### getMaxInProcessPerConnection : 20
AWSNeptuneSchemaCreation Time taken in getting AWS Neptune traversal :: 20 .ms ####
AWSNeptuneSchemaCreation Done getting traversal from neptune ####
AWSNeptuneSchemaCreation Executing Iterate : GRAPHDB_JU_CHILD_V
AWSNeptuneSchemaCreation Explain : Traversal Explanation
Original Traversal   [AddVertexStartStep({label=[GRAPHDB_JU_CHILD_V]}), AddPropertyStep({key=[Attr_Date], value=[Tue Jan 25 00:00:00 IST 2022]}), AddPropertyStep({key=[NotNull_Mandatory_Attribute], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_Byte], value=[0]}), AddPropertyStep({key=[Attr_Long], value=[12345678910]}), AddPropertyStep({key=[Mandatory_Attribute], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_Integer], value=[0]}), AddPropertyStep({key=[NotNull_ReadOnly_Mandatory_Attribute], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[StringTest], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_Float], value=[4.515]}), AddPropertyStep({key=[ReadOnly_Mandatory_Attribute], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[ReadOnlyAttribute], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_String Special.Atr1], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_Double], value=[10.51]}), AddPropertyStep({key=[Attr_Decimal], value=[10.51]}), AddPropertyStep({key=[Attr_String], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_String Special,Atr3], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[NotNull_ReadOnly_Attribute], value=[GRAPHDB_JU_CHILD_V_0]}), AddPropertyStep({key=[Attr_Boolean], value=[true]}), AddPropertyStep({key=[Attr_DateTime], value=[Tue Jan 25 07:07:07 IST 2022]}), AddPropertyStep({key=[Attr_Short], value=[0]}), AddPropertyStep({key=[Attr_Integer Special.Atr2], value=[0]}), AddPropertyStep({key=[NotNull_Attribute], value=[GRAPHDB_JU_CHILD_V_0]})]\n\nRemoteStrategy [D]   [RemoteStep(DriverServerConnection-address.some-region.neptune.amazonaws.com/ . . . :8182 [graph=g])]\n\nFinal Traversal      [RemoteStep(DriverServerConnection-address.some-region.neptune.amazonaws.com/ . . . :8182 [graph=g])]
ERROR org.apache.tinkerpop.gremlin.driver.Client - Could not initialize client for Host{address=address.some-region.neptune.amazonaws.com/ . . . :8182, hostUri=wss://address.some-region.neptune.amazonaws.com:8182/gremlin}
ERROR org.apache.tinkerpop.gremlin.driver.Client - Initialization failed
java.util.concurrent.CompletionException: Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
	at org.apache.tinkerpop.gremlin.driver.ConnectionPool.<init>(ConnectionPool.java:164)
	at org.apache.tinkerpop.gremlin.driver.ConnectionPool.<init>(ConnectionPool.java:103)
	at org.apache.tinkerpop.gremlin.driver.ConnectionPool.<init>(ConnectionPool.java:98)
	at org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient.lambda$new$5(Client.java:584)
	at org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient.lambda$initializeImplementation$0(Client.java:534)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.apache.tinkerpop.gremlin.driver.exception.ConnectionException: Could not open Connection{channel=null host=Host{address=address.some-region.neptune.amazonaws.com/ . . . :8182, hostUri=wss://address.some-region.neptune.amazonaws.com:8182/gremlin} isDead=false borrowed=0 pending=0 markedReplaced=false closing=false created=2026-09-23T11:01:13.341048315Z thread=gremlin-driver-conn-scheduler-1}
	at org.apache.tinkerpop.gremlin.driver.Connection.<init>(Connection.java:142)
	at org.apache.tinkerpop.gremlin.driver.ConnectionFactory.create(ConnectionFactory.java:34)
	at org.apache.tinkerpop.gremlin.driver.ConnectionPool.lambda$new$0(ConnectionPool.java:130)
	... 7 more
Caused by: io.netty.channel.ConnectTimeoutException: connection timed out after 30000 ms: address.some-region.neptune.amazonaws.com/ . . . :8182
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:308)
	at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
	at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:160)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:148)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:141)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:535)
	at io.netty.channel.SingleThreadIoEventLoop.run(SingleThreadIoEventLoop.java:201)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:1204)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	... 1 more
	Suppressed: java.util.concurrent.CompletionException: Rethrowing promise failure cause
		at io.netty.util.concurrent.DefaultPromise.rethrowIfFailed(DefaultPromise.java:686)
		at io.netty.util.concurrent.DefaultPromise.sync(DefaultPromise.java:420)
		at io.netty.channel.DefaultChannelPromise.sync(DefaultChannelPromise.java:119)
		at io.netty.channel.DefaultChannelPromise.sync(DefaultChannelPromise.java:30)
		at org.apache.tinkerpop.gremlin.driver.Connection.<init>(Connection.java:118)
		at org.apache.tinkerpop.gremlin.driver.ConnectionFactory.create(ConnectionFactory.java:34)
		at org.apache.tinkerpop.gremlin.driver.ConnectionPool.lambda$new$0(ConnectionPool.java:130)
		at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
		at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
		at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
		at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
		at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
		at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
		... 1 more
AWSNeptuneSchemaCreation Exception thrown for : GRAPHDB_JU_CHILD_V Exception : org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException: org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException: java.util.concurrent.CompletionException: Could not initialize 2 (minPoolSize) connections in pool. Successful connections=0. Closing the connection pool.
AWSNeptuneSchemaCreation Out createData .. :30074 .ms 

asked 2 months ago128 views

1 Answer
0

Diagnosis

This is a network reachability problem. IAM, SSL, and your connection pool settings are not the cause. The key line in the trace is:

io.netty.channel.ConnectTimeoutException: connection timed out after 30000 ms: ...:8182

The client tried to open a TCP connection to port 8182 and got no reply at all for 30 seconds. The TLS handshake and IAM (SigV4) signing had not started yet. Other failures would look different:

CauseTypical error
Blocked or unreachable network pathConnectTimeoutException (your case)
Nothing listening on the port / wrong portConnection refused
TLS problemSSLHandshakeException
IAM or SigV4 problemHTTP 403 during the WebSocket handshake

The "20 ms to get traversal" log is misleading. The driver connects lazily, so the connection is only attempted at the first iterate(). That's why the error shows up there.

Likely causes, most common first

  1. The client is not inside the Neptune VPC. By default Neptune has no public access. A laptop, an on-prem server, or a Lambda not attached to the VPC can't reach it. Check the IP the endpoint resolves to (it's masked in your log). If it's private (10.x, 172.16–31.x, 192.168.x), the client needs a network path into that VPC.
  2. The security group doesn't allow the client. The security group on the Neptune cluster needs an inbound rule for TCP 8182 from the client's security group or CIDR. This is the most common cause when the client is in the same VPC.
  3. NACLs or route tables. Check the subnet NACLs, including the return traffic on ephemeral ports 1024–65535. If the client is in another VPC or on-prem, also check the peering, Transit Gateway, VPN, or Direct Connect routes.
  4. A corporate firewall or proxy blocks outbound 8182.
  5. The cluster isn't available. It may be stopped, have no instances, or be in the middle of a failover or maintenance. Confirm the status is available in the console.
  6. Wrong endpoint. Make sure you're using the cluster endpoint for writes (x.cluster-yyy.<region>.neptune.amazonaws.com) and not a stale instance endpoint.

Quick checks from the same host that runs the Java app

# 1. DNS: should resolve (usually to a private IP)
nslookup <your-neptune-endpoint>

# 2. TCP reachability: this is the critical test
nc -vz <your-neptune-endpoint> 8182

# 3. HTTPS: any HTTP response, even 403 with IAM enabled, proves the network path works
curl -v https://<your-neptune-endpoint>:8182/status
  • If nc or curl hang and time out, fix the security group, routing, or VPC placement.
  • If they connect but the Java app still fails, the problem is on the app side (for example a JVM proxy setting, or a different host or container network than you expect).

Fixes by scenario

  • App on EC2, ECS, or EKS in the same VPC: add an inbound rule to the Neptune security group allowing TCP 8182 from the app's security group.
  • Lambda: attach it to the Neptune VPC's private subnets with a security group that Neptune allows.
  • Local development: use an SSH tunnel through a bastion host, or SSM port forwarding, then add a hosts-file entry that maps the Neptune hostname to 127.0.0.1. The hosts entry keeps the SSL certificate hostname check passing. Alternatively, use Client VPN.
  • Direct access from outside AWS: newer Neptune engine versions support public endpoints (IAM auth required). Check whether your engine version supports it and whether it fits your security policy before you enable it.

Once connectivity works

  • Your pool settings are fine. You can also set minConnectionPoolSize explicitly (for example 1–2).
  • Keep the IAM signing setup as it is. If you then get a 403, check that the credentials in the client's environment have neptune-db:* permissions and that the region used for signing matches the cluster's region.

If you tell me where the Java app runs (EC2, Lambda, local machine, on-prem), I can narrow this down to the exact settings to change.

EXPERT

answered 2 months ago

EXPERT

reviewed 2 months ago

  • Hi, After executing curl -v https://<your-neptune-endpoint>:8182/status I received a following error on my java application using code

    HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
    
    HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://" + NEPTUNE_ENDPOINT + ":" + PORT + "/status")).timeout(Duration.ofSeconds(5)).GET().build();
    
    HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
    
    logger.debug("NeptuneNetworkCheckerTest :: HTTP Response Code: " + response.statusCode());
    logger.debug("NeptuneNetworkCheckerTest :: Response Body: " + response.body());
    
    if (response.statusCode() >= 400) {
    	fail("NeptuneNetworkCheckerTest :: HTTPS Status Check Failed. Response Code: " + response.statusCode());
    }
    

    The logged exception is

    org.opentest4j.AssertionFailedError: NeptuneNetworkCheckerTest :: HTTPS Request Failed: HTTP connect timed out
    Caused by: java.net.http.HttpConnectTimeoutException: HTTP connect timed out
    	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:949)
    	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:133)
    	at com.eqtechnologic.eqube.graphdbtest.awsneptune.connection.NeptuneNetworkCheckerTest.testHTTPSStatus(NeptuneNetworkCheckerTest.java:73)
    	... 87 more
    Caused by: java.net.http.HttpConnectTimeoutException: HTTP connect timed out
    	at java.net.http/jdk.internal.net.http.ResponseTimerEvent.handle(R
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.