Could not open a new Neo4j session: Unable to connect to localhost:7687

Hi,

After opening Neo4j Desktop and open related database, I try to send some requests from Postman but I get this kind of error.

Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.transaction.TransactionSystemException: Could not open a new Neo4j session: Unable to connect to localhost:7687, ensure the database is running and that there is a working network connection to it.; nested exception is org.neo4j.driver.exceptions.ServiceUnavailableException: Unable to connect to localhost:7687, ensure the database is running and that there is a working network connection to it.] with root cause

java.net.ConnectException: Connection refused: no further information

How can I fix it?

Here is my repository link : Link

This is also valid for the http thread https://community.neo4j.com/t5/drivers-stacks/cannot-send-any-request-from-my-spring-boot-running-in-dockewith/td-p/57359

You have to define the listening and advertised address in the config:

dbms.default_listen_address=0.0.0.0
and

dbms.connector.bolt.advertised_address=<external_ip_of_this_host>
dbms.connector.http.advertised_address=<external_ip_of_this_host>
dbms.connector.https.advertised_address=<external_ip_of_this_host>

If you don't know the addresses, put in 0.0.0.0

Please have a look at the docker documentation for this, because there is a certain pattern to get this right for the environment variables. https://neo4j.com/docs/operations-manual/current/docker/configuration/#docker-environment-variables

NEO4J_dbms_connector_http_advertised__address

etc. should be the pattern from those rules.