Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
proencio
HOBBYOP

2 years ago

I deployed a Java Spring Boot application using Github. I created the variables but can't access the database.

DDL_BD=false

NIXPACKS_JDK_VERSION=11

PGDATABASE=${{Postgres.PGDATABASE}}

PGPASSWORD=${{Postgres.PGPASSWORD}}

PGPORT=${{Postgres.PGPORT}}

PGPRIVATEHOST=${{Postgres.PGPRIVATEHOST}}

PGUSER=${{Postgres.PGUSER}}

PORT=8080

spring.profiles.active=prod

@Configuration

@Profile("prod")

public class prod extends BaseConfig {

@Autowired
public prod() {  
	this.host = System.getenv("PGPRIVATEHOST");
	this.port = Integer.valueOf(System.getenv("PGPORT"));
	this.dbName = System.getenv("PGDATABASE");
	this.user = System.getenv("PGUSER");
	
    this.password = System.getenv("POSTGRES_PASSWORD");
    this.dbGenerateDDL =  Boolean.parseBoolean(System.getenv("DDL_BD"));
    
    System.out.println("host " + this.host);
}

}

2024-04-02 15:28:48.791 INFO 7 --- [ main] b.c.f.GestorFlorLaranjeiraApplication : The following 1 profile is active: "prod"

2024-04-02 15:28:49.705 INFO 7 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.

2024-04-02 15:28:49.725 INFO 7 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 JPA repository interfaces.

2024-04-02 15:28:50.436 INFO 7 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)

2024-04-02 15:28:50.450 INFO 7 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]

2024-04-02 15:28:50.450 INFO 7 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.62]

2024-04-02 15:28:50.544 INFO 7 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext

2024-04-02 15:28:50.544 INFO 7 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1695 ms

@@@@@@ prod DATABASE: jdbc:postgresql://postgres.railway.internal:54356/railway

2024-04-02 15:28:50.728 INFO 7 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]

2024-04-02 15:28:50.802 INFO 7 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.8.Final

2024-04-02 15:28:50.846 INFO 7 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}

2024-04-02 15:28:51.354 INFO 7 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...

2024-04-02 15:28:52.412 ERROR 7 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.

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

$10 Bounty

2 Replies

hamzaelbouzidi03
PRO

10 months ago

Brother, did you find the solution? I faced the same error.


hamzaelbouzidi03

Brother, did you find the solution? I faced the same error.

clashing
FREE

10 months ago

Are you using a Docker image to deploy the service?


Welcome!

Sign in to your Railway account to join the conversation.

Loading...