DependencyTrack / DependencyTrack/dependency-track
Dependency Track can not connect to Postgres database
- Dominant language
- Java
- Stars
- 4.2k
- Forks
- 811
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 237
Description
### Current Behavior
Current Behavior
I have Postgres db running on the AWS Linux (ubuntu 22.04) instance (Not Dockerised) , on the same instance I am running dependency-track docker compose container. I have tried the ALPINE_DATABASE_URL wirh both hostname and ip_address. the docker-compose.yml contains:
services:
dtrack-apiserver:
image: dependencytrack/apiserver
environment:
# The Dependency-Track container can be configured using any of the
# available configuration properties defined in:
# https://docs.dependencytrack.org/getting-started/configuration/
# All properties are upper case with periods replaced by underscores.
#
# Database Properties
- ALPINE_DATABASE_MODE=external
- ALPINE_DATABASE_URL=jdbc:postgresql://10.111.112.58:5432/dttrack
# - ALPINE_DATABASE_URL=jdbc:postgresql://SGAWSLD000SNR01:5432/dttrack
- ALPINE_DATABASE_DRIVER=org.postgresql.Driver
- ALPINE_DATABASE_USERNAME=dtrack
- ALPINE_DATABASE_PASSWORD=changeme1
- ALPINE_DATABASE_POOL_ENABLED=true
I am getting below error in API server log -
2023-11-27 09:01:58,509 INFO [Config] Initializing Configuration
2023-11-27 09:01:58,510 INFO [Config] System property alpine.application.properties not specified
2023-11-27 09:01:58,511 INFO [Config] Loading application.properties from classpath
2023-11-27 09:01:58,524 INFO [Config] --------------------------------------------------------------------------------
2023-11-27 09:01:58,525 INFO [Config] Application: Dependency-Track
2023-11-27 09:01:58,526 INFO [Config] Version: 4.9.1
2023-11-27 09:01:58,527 INFO [Config] Built-on: 2023-10-30T12:04:30Z
2023-11-27 09:01:58,532 INFO [Config] --------------------------------------------------------------------------------
2023-11-27 09:01:58,533 INFO [Config] Framework: Alpine
2023-11-27 09:01:58,534 INFO [Config] Version : 2.2.3
2023-11-27 09:01:58,535 INFO [Config] Built-on: 2023-09-21T16:07:30Z
2023-11-27 09:01:58,535 INFO [Config] --------------------------------------------------------------------------------
2023-11-27 09:01:58,695 INFO [RequirementsVerifier] Initializing requirements verifier
2023-11-27 09:01:58,696 INFO [UpgradeInitializer] Initializing upgrade framework
2023-11-27 09:02:09,183 ERROR [UpgradeMetaProcessor] An error occurred connecting to the database.
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:354)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:263)
at org.postgresql.Driver.makeConnection(Driver.java:443)
at org.postgresql.Driver.connect(Driver.java:297)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at alpine.server.upgrade.UpgradeMetaProcessor.createConnection(UpgradeMetaProcessor.java:187)
at alpine.server.upgrade.UpgradeMetaProcessor.(UpgradeMetaProcessor.java:63)
at org.dependencytrack.upgrade.UpgradeInitializer.contextInitialized(UpgradeInitializer.java:56)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1050)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:624)
at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:985)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:740)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1304)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:902)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:532)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171)
at org.eclipse.jetty.server.Server.start(Server.java:470)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:89)
at org.eclipse.jetty.server.Server.doStart(Server.java:415)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at alpine.embedded.EmbeddedJettyServer.main(EmbeddedJettyServer.java:100)
Caused by: java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(Unknown Source)
at java.base/sun.nio.ch.NioSocketImpl.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.createSocket(PGStream.java:243)
at org.postgresql.core.PGStream.(PGStream.java:98)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:132)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:258)
... 26 common frames omitted
2023-11-27 09:02:09,186 ERROR [UpgradeInitializer] An error occurred determining database schema version. Unable to continue.
alpine.server.upgrade.UpgradeException: An error occurred connecting to the database.
at alpine.server.upgrade.UpgradeMetaProcessor.createConnection(UpgradeMetaProcessor.java:193)
at alpine.server.upgrade.UpgradeMetaProcessor.(UpgradeMetaProcessor.java:63)
at org.dependencytrack.upgrade.UpgradeInitializer.contextInitialized(UpgradeInitializer.java:56)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1050)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:624)
at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:985)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:740)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:392)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1304)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:902)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:306)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:532)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171)
at org.eclipse.jetty.server.Server.start(Server.java:470)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:89)
at org.eclipse.jetty.server.Server.doStart(Server.java:415)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at alpine.embedded.EmbeddedJettyServer.main(EmbeddedJettyServer.java:100)
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:354)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:263)
at org.postgresql.Driver.makeConnection(Driver.java:443)
at org.postgresql.Driver.connect(Driver.java:297)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at alpine.server.upgrade.UpgradeMetaProcessor.createConnection(UpgradeMetaProcessor.java:187)
... 19 common frames omitted
Caused by: java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(Unknown Source)
at java.base/sun.nio.ch.NioSocketImpl.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.createSocket(PGStream.java:243)
at org.postgresql.core.PGStream.(PGStream.java:98)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:132)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:258)
... 26 common frames omitted
### Steps to Reproduce
1.Start a docker-container with the official image dependencytrack docker compose
### Expected Behavior
Docker container runs normally
### Dependency-Track Version
4.9.1
### Dependency-Track Distribution
Container Image
### Database Server
PostgreSQL
### Database Server Version
14.2
### Browser
Google Chrome
### Checklist
- [X] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/dependency-track/blob/master/CONTRIBUTING.md#filing-issues)
- [X] I have checked the [existing issues](https://github.com/DependencyTrack/dependency-track/issues) for whether this defect was already reported
Contributor guide
Assessment
This issue has not been assessed yet.