New Installation on Ubuntu 22.04

Hello there,
I am new to dhis2 and I am trying to install it on Ubunto 22.04 following the official guide at
https://docs.dhis2.org/en/manage/performing-system-administration/dhis-core-version-master/installation.html#install_tomcat_dhis2_installation

I am getting a 404 page when trying to access DHIS.

I am using java-11, Tomcat 9, Postgres 14

and here are my logs :

<6>Command line argument: -Djava.io.tmpdir=/home/dhis/tomcat-dhis/temp
<6>Loaded Apache Tomcat Native library [1.2.31] using APR version [1.7.0].
<6>APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
<6>APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
<6>OpenSSL successfully initialized [OpenSSL 3.0.2 15 Mar 2022]
<6>Initializing ProtocolHandler ["http-nio-8008"]
<6>Server initialization in [823] milliseconds
<6>Starting service [Catalina]
<6>Starting Servlet engine: [Apache Tomcat/9.0.58 (Ubuntu)]
<6>Deploying web application archive [/home/dhis/tomcat-dhis/webapps/ROOT.war]
<6>At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
* INFO  2023-12-04T12:38:32,325 Context variable dhis2-home not set (LogOnceLogger.java [main])
* INFO  2023-12-04T12:38:32,333 System property dhis2.home not set (LogOnceLogger.java [main])
* INFO  2023-12-04T12:38:32,339 Environment variable DHIS2_HOME points to /home/dhis/config (LogOnceLogger.java [main])
* INFO  2023-12-04T12:38:32,387 File /home/dhis/config/dhis-google-auth.json does not exist (LogOnceLogger.java [main])
* INFO  2023-12-04T12:38:32,388 Could not find dhis-google-auth.json (LogOnceLogger.java [main])
* INFO  2023-12-04T12:38:35,036 Monitoring metric for key monitoring.dbpool.enabled is disabled (MetricsEnabler.java [main])
* INFO  2023-12-04T12:38:35,039 Monitoring metric for key monitoring.uptime.enabled is disabled (MetricsEnabler.java [main])
* INFO  2023-12-04T12:38:35,041 Monitoring metric for key monitoring.jvm.enabled is disabled (MetricsEnabler.java [main])
* INFO  2023-12-04T12:38:35,043 Monitoring metric for key monitoring.cpu.enabled is disabled (MetricsEnabler.java [main])
* INFO  2023-12-04T12:38:35,045 Monitoring metric for key monitoring.hibernate.enabled is disabled (MetricsEnabler.java [main])
* INFO  2023-12-04T12:38:35,053 Monitoring metric for key monitoring.api.enabled is disabled (MetricsEnabler.java [main])
* INFO  2023-12-04T12:38:39,981 Hibernate configuration loaded: dialect: 'org.hisp.dhis.hibernate.dialect.DhisPostgresDialect', region factory: 'org.hibernate.cache.ehcache.EhCacheRegionFactory', connection pool max size: null (DefaultHibernateConfigurationProvider.java [main])

* WARN  2023-12-04T12:39:10,823 com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@3b821c37 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:  (Slf4jMLog.java [C3P0PooledConnectionPoolManager[identityToken->z8kfsxb0ehcoao1cfh2k3|2bcd8d2b]-HelperThread-#2])
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:342) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:253) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.Driver.makeConnection(Driver.java:434) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.Driver.connect(Driver.java:291) ~[postgresql-42.5.3.jar:42.5.3]
        at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908) ~[c3p0-0.9.5.5.jar:0.9.5.5]
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) ~[mchange-commons-java-0.2.19.jar:0.2.19]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) ~[?:?]
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) ~[?:?]
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) ~[?:?]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
        at java.net.Socket.connect(Socket.java:609) ~[?:?]
        at org.postgresql.core.PGStream.createSocket(PGStream.java:243) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.PGStream.<init>(PGStream.java:98) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:132) ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:258) ~[postgresql-42.5.3.jar:42.5.3]
        ... 13 more```
1 Like

Hi @Aghiad

Welcome to the DHIS2 Community of Practice! :tada:

Thank you for including the logs…

The .war file should be renamed to dhis.war

Please make sure that you have given the dhis user the proper authorities to access the dhis.conf in (/home/dhis/config)

Please review all the PostgreSQL configurations, make sure that it is running and that no VPN/Firewall is blocking its connection. Additionally, you might want to check that the port 5432 is not used by another process.

Thank you, @Aghiad.

Based on the displayed error message, it indicates that your DHIS2 instance is unable to establish connections with your PostgreSQL server. What could be the potential causes for this issue?

  1. To ensure the proper functioning of your PostgreSQL server, first, check its status by running ps aux | grep postgres. Confirm that the PostgreSQL port (default: 5432) is actively listening using the ss -tunlp command. If the port differs, it may indicate that PostgreSQL is either inactive or listening on an alternate port. Prior to launching your DHIS instance, assess the connection to PostgreSQL with the psql utility using the command psql -U dhis -h 127.0.0.1 -W. This allows you to verify connectivity, assuming the use of the ‘dhis’ database user.

  2. Once you’ve confirmed the database is operational, verify that the ‘dhis’ database is created and owned by the ‘dhis’ user. Inspect the pg_hba.conf file to ensure there is an entry permitting this user to access the database through the TCP socket. For a standard PostgreSQL 14 installation on an Ubuntu 22.04 server using apt, locate the file at /etc/postgresql/14/main/pg_hba.conf.

  3. Examine your dhis.conf configuration file for the database connection details. Confirm that the line specifying the PostgreSQL server’s IP address and password is accurately configured.

  4. Simplify the process of setting up your instance by considering the use of dhis2-server-tools. This tool automates the entire installation process, streamlining the setup of your DHIS2 instance.

1 Like