Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.net.UnknownHostException: postgres #179

Closed
DrewCyber opened this issue Apr 20, 2020 · 2 comments
Closed

java.net.UnknownHostException: postgres #179

DrewCyber opened this issue Apr 20, 2020 · 2 comments

Comments

@DrewCyber
Copy link

DrewCyber commented Apr 20, 2020

reportportal/service-authorization:5.1.0
Probably hardcoded postgres hostname.

I'm trying to deploy RP with standalone postgres instance.
I removed postgres part from docker-compose file.
UAT part below:

uat:
    image: reportportal/service-authorization:5.1.0
    # ports:
    #  - "9999:9999"
    environment:
      - RP_PROFILES=docker
      - POSTGRES_SERVER=pg.aws-int.******.com
      - POSTGRES_PORT=5432
      - POSTGRES_USER=rpuser
      - POSTGRES_PASSWORD=*********
      - POSTGRES_DB=reportportal
      - RP_BINARYSTORE_TYPE=minio
      - RP_BINARYSTORE_MINIO_ENDPOINT=http://minio:9000
      - RP_BINARYSTORE_MINIO_ACCESSKEY=minio
      - RP_BINARYSTORE_MINIO_SECRETKEY=*******
      - RP_SESSION_LIVE=86400 #in seconds
    labels:
      - "traefik.backend=uat"
      - "traefik.frontend.rule=PathPrefixStrip:/uat"
      - "traefik.enable=true"
      - "traefik.port=9999"
      - "traefik.tags=reportportal"
    restart: always

Getting error:

2020-04-20 08:09:40.464  INFO 8 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-04-20 08:09:41.541 ERROR 8 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

org.postgresql.util.PSQLException: The connection attempt failed.
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:297)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
	at org.postgresql.Driver.makeConnection(Driver.java:459)
	at org.postgresql.Driver.connect(Driver.java:261)
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
	at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
	at com.epam.ta.reportportal.config.DataSourceConfig.dataSource(DataSourceConfig.java:41)
	at com.epam.ta.reportportal.config.DataSourceConfig$$EnhancerBySpringCGLIB$$2086a708.CGLIB$dataSource$0(<generated>)
	at com.epam.ta.reportportal.config.DataSourceConfig$$EnhancerBySpringCGLIB$$2086a708$$FastClassBySpringCGLIB$$262d4e97.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
	at com.epam.ta.reportportal.config.DataSourceConfig$$EnhancerBySpringCGLIB$$2086a708.dataSource(<generated>)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:297)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
	at org.postgresql.Driver.makeConnection(Driver.java:459)
	at org.postgresql.Driver.connect(Driver.java:261)
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
	... 134 common frames omitted
Caused by: java.net.UnknownHostException: postgres
	at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
	at java.base/java.net.Socket.connect(Unknown Source)
	at org.postgresql.core.PGStream.<init>(PGStream.java:81)
	at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:93)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197)
	... 143 common frames omitted

And can be fixed with adding to docker-compose file:

extra_hosts:
  - "postgres:<postgres_ip_here>"

Same for API container. reportportal/service-api:5.1.0

@DrewCyber DrewCyber changed the title UnknownHostException: postgres java.net.UnknownHostException: postgres Apr 20, 2020
@pbortnik
Copy link
Collaborator

#181

@pbortnik
Copy link
Collaborator

Can be fixed with adding to docker-compose file the RP_DB_HOST env variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants