I need to access remotely to a dockered Neo4j using the public IP address, but when I configure the IP address via parameters, the connection through http via 7474 port fails and neo4j.log shows these exceptions:
org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.bolt.protocol.common.connector.netty.SocketNettyConnector@2548fc01' was successfully initialized, but failed to start. Please see the attached cause exception "bind(..) failed: Cannot assign requested address".
org.neo4j.configuration.helpers.PortBindException: An error occurred while trying to bind to the socket /<server_public_IP>:7687
io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Cannot assign requested address
The server is running on an AWS virtual server with these settings:
Virtualization: amazon
Operating System: Ubuntu 22.04.3 LTS
Kernel: Linux 6.2.0-1017-aws
Architecture: arm64
I am using the latest docker image for neo4j 5.15.0
As instructed in the Operations manual, and this post the command I am using to create and run the container with the neo4j image is:
sudo docker run -d
--name=neo4jdocker
--restart always
--publish=7474:7474 --publish=7687:7687
--env NEO4J_AUTH=neo4j/
--env NEO4J_server_memory_heap_initial__size=12288m
--env NEO4J_server_memory_heap_max__size=20480m
--env NEO4J_server_default__listen__address=0.0.0.0
--env NEO4J_server_default__advertised_address=<server_public_IP>
--env NEO4J_server_bolt_enabled=true
--env NEO4J_server_bolt_tls__level=DISABLED
--env NEO4J_server_bolt_listen__address=0.0.0.0:7687
--env NEO4J_server_bolt_advertised__address=<server_public_IP>:7687
--env NEO4J_server_http_enabled=true
--env NEO4J_server_http_listen__address=0.0.0.0:7474
--env NEO4J_server_http_advertised__address=<server_public_IP>:7474
--env NEO4J_server_https_enabled=false
--volume=/home/ubuntu/ocean_route_prediction/data:/data
--volume=/home/ubuntu/ocean_route_prediction/import:/import
--volume=/home/ubuntu/ocean_route_prediction/logs:/logs
--volume=/home/ubuntu/ocean_route_prediction/plugins:/plugins
neo4j:5.15.0
Then the Neo4j finds something wrong and tries to restart:
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a641248b8d9 neo4j:5.15.0 "tini -g -- /startup…" About a minute ago Restarting (1) 18 seconds ago neo4jdocker
On the other hand, when I create the container without the public IP configuration settings, everything works as expected locally at the server machine:
sudo docker run -d
--name=neo4jdocker
--restart always
--publish=7474:7474 --publish=7687:7687
--env NEO4J_AUTH=neo4j/
--env NEO4J_server_memory_heap_initial__size=12288m
--env NEO4J_server_memory_heap_max__size=20480m
--env NEO4J_server_default__listen__address=0.0.0.0
--volume=/home/ubuntu/ocean_route_prediction/data:/data
--volume=/home/ubuntu/ocean_route_prediction/import:/import
--volume=/home/ubuntu/ocean_route_prediction/logs:/logs
--volume=/home/ubuntu/ocean_route_prediction/plugins:/plugins
neo4j:5.15.0
Docker reports everything ok:
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5432bafedd5 neo4j:5.15.0 "tini -g -- /startup…" 34 minutes ago Up 34 minutes 0.0.0.0:7474->7474/tcp, :::7474->7474/tcp, 7473/tcp, 0.0.0.0:7687->7687/tcp, :::7687->7687/tcp neo4jdocker
I even have access to the web interface:
{
"bolt_routing" : "neo4j://localhost:7687",
"transaction" : "http://localhost:7474/db/{databaseName}/tx",
"bolt_direct" : "bolt://localhost:7687",
"neo4j_version" : "5.15.0",
"neo4j_edition" : "community"
}
And obviously the ports appear to be listened by the docker container:
sudo lsof -i -P -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 2179741 root 4u IPv4 5668735 0t0 TCP *:7687 (LISTEN)
docker-pr 2179747 root 4u IPv6 5667661 0t0 TCP *:7687 (LISTEN)
docker-pr 2179759 root 4u IPv4 5670560 0t0 TCP *:7474 (LISTEN)
docker-pr 2179766 root 4u IPv6 5669470 0t0 TCP *:7474 (LISTEN)
And neo4j.log shows expected messages:
2023-12-27 15:30:10.305+0000 INFO Starting...
2023-12-27 15:30:11.033+0000 INFO This instance is ServerId{57946358} (57946358-4700-4f22-bb6f-9bf3d5559522)
2023-12-27 15:30:11.614+0000 INFO ======== Neo4j 5.15.0 ========
2023-12-27 15:30:12.773+0000 INFO Bolt enabled on 0.0.0.0:7687.
2023-12-27 15:30:13.346+0000 INFO HTTP enabled on 0.0.0.0:7474.
2023-12-27 15:30:13.347+0000 INFO Remote interface available at http://localhost:7474/
2023-12-27 15:30:13.349+0000 INFO id: 0101D8EABC7A7290033198E46D8969889C893917A0BC961C751565FB9B130D40
2023-12-27 15:30:13.350+0000 INFO name: system
2023-12-27 15:30:13.350+0000 INFO creationDate: 2023-12-22T22:57:40.961Z
2023-12-27 15:30:13.350+0000 INFO Started.
So, at this point, my money is on a problem with the network configuration parameters. Can you please help me to identify what I did wrong? What is missing?