0

I have done ssh port forwarding which listens to 2000 in my local. So the service is running on localhost:2000, it is Neo4J server. In my local, I am able to connect with Neo4J using Neo4J desktop by giving bolt://localhost:2000 and can look at the datas.

but i am not able to connect with host bolt://localhost:2000 in docker container.

I looked at the answers here

From inside of a Docker container, how do I connect to the localhost of the machine?

I added extra hosts in docker-compose.yml

flask_service:
    build:
      context: ./project
      dockerfile: my_dockerfile
    container_name: flask_container
    stdin_open: true
    tty: true
    ports:
      - 5000:5000
    extra_hosts:
      - "myhost:175.1.344.136"

175.1.344.136 being my host IP and I have used both bolt://175.1.344.136:2000 and bolt://myhost:2000 inside container but it is not connecting. Also i want to know which is the right way bolt://175.1.344.136:2000 or bolt://myhost:2000

I get an error

2021-05-25T10:53:55+0000.060 [INFO] neo4j_proxy.__init__:74 (8:Thread-11) - NEO4J endpoint: bolt://myhost:2000
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/neobolt/direct.py", line 831, in _connect
    s.connect(resolved_address)
ConnectionRefusedError: [Errno 111] Connection refused

I am using MacOs, Please help me resolve this.

Thanks in advance!

young_minds1
  • 1,181
  • 3
  • 10
  • 25

1 Answers1

-1

you need to use the container service name neo4j and default port 7687 to use inside the same docker host.

bolt://neo4j:7687

version: "3.8"
services:
    neo4j:
        image: neo4j:3.4.4-enterprise
        ports:
            - 7474:7474
            - 7687:7687
    my_service:
        build:
          context: .
        environment:
          DATABASE_URL: "bolt://neo4j:7687"
  • i want to use neo4j, which is running in my host at port 2000. not of the container. solution you have suggested is by creating new container for neo4J, which is not the solution for my problem. if i have miss read it. Please correct me – young_minds1 May 25 '21 at 12:27
  • use bolt://{IP}:{NEO4J_PORT} - bolt://175.1.344.136:2000 vrtify the network inside for the docker container. – Ankush Kumar Behera Jun 01 '21 at 21:47