Search code examples
javapostgresqlspring-bootintellij-idea

encounter an error while connecting to PostgreSQL in IntelliJ with Spring Boot


I'm experiencing a PostgreSQL connection error when building a new project in IntelliJ with Spring Boot. The error message is as follows, and it appears to be a typical input information error, but I can't seem to find the cause (I've confirmed that the same connection information works when used in a previous project, so it seems to be a configuration issue within the current project).

org.postgresql.util.PSQLException: Connection to localhost:7773 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

However, when I use the same information in IntelliJ's database connection for the project, it connects without any issues. database connection

application.yml

build.gradle

application

error_log1

error_log2

"Is there anyone who might know the cause? I've been struggling with this all day. TT"


Solution

  • I think the problem you could solve is:

    • Ensure that PostgreSQL is configured to listen on the expected address and port. You can find the PostgreSQL configuration files in the PostgreSQL data directory.
    • Try to use your IP address instead of localhost
    • Other ways try this answer : https://stackoverflow.com/a/20830893/18567686