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

**URL:** <https://community.neo4j.com/t/could-not-open-a-new-neo4j-session-unable-to-connect-to-localhost-7687/59965>\
**Category:** Drivers & Stacks\
**Tags:** migrated\
**Created:** [July 3, 2022, 11:49am UTC](https://community.neo4j.com/t/could-not-open-a-new-neo4j-session-unable-to-connect-to-localhost-7687/59965 "2022-07-03T11:49:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sngermiyanoglu](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sngermiyanoglu](https://community.neo4j.com/u/sngermiyanoglu)\
**Post date:** [July 3, 2022, 11:49am UTC](https://community.neo4j.com/t/could-not-open-a-new-neo4j-session-unable-to-connect-to-localhost-7687/59965/1 "2022-07-03T11:49:49Z")

</div>

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

 ![screenshot_neo4j_12.PNG](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/5/9/59974ac589a5ef2ce88483f970241bb57de6c14e.png "screenshot\_neo4j\_12.PNG")

How can I fix it?

Here is my repository link : [Link](https://github.com/Rapter1990/SpringBootNeo4jShortestPath)

---

<div class="post-metadata">

**Author:** ![gerrit.meier](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gerrit.meier/32/27374_2.png) [@gerrit.meier](https://community.neo4j.com/u/gerrit.meier)\
**Post date:** [July 4, 2022, 6:42am UTC](https://community.neo4j.com/t/could-not-open-a-new-neo4j-session-unable-to-connect-to-localhost-7687/59965/2 "2022-07-04T06:42:58Z")

</div>

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

```auto
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](https://neo4j.com/docs/operations-manual/current/docker/configuration/#docker-environment-variables)

```auto
NEO4J_dbms_connector_http_advertised__address

```

etc. should be the pattern from those rules.
