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

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:
<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 ( [main])
* INFO  2023-12-04T12:38:32,333 System property dhis2.home not set ( [main])
* INFO  2023-12-04T12:38:32,339 Environment variable DHIS2_HOME points to /home/dhis/config ( [main])
* INFO  2023-12-04T12:38:32,387 File /home/dhis/config/dhis-google-auth.json does not exist ( [main])
* INFO  2023-12-04T12:38:32,388 Could not find dhis-google-auth.json ( [main])
* INFO  2023-12-04T12:38:35,036 Monitoring metric for key monitoring.dbpool.enabled is disabled ( [main])
* INFO  2023-12-04T12:38:35,039 Monitoring metric for key monitoring.uptime.enabled is disabled ( [main])
* INFO  2023-12-04T12:38:35,041 Monitoring metric for key monitoring.jvm.enabled is disabled ( [main])
* INFO  2023-12-04T12:38:35,043 Monitoring metric for key monitoring.cpu.enabled is disabled ( [main])
* INFO  2023-12-04T12:38:35,045 Monitoring metric for key monitoring.hibernate.enabled is disabled ( [main])
* INFO  2023-12-04T12:38:35,053 Monitoring metric for key monitoring.api.enabled is disabled ( [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 ( [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:  ( [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( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.ConnectionFactory.openConnection( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.jdbc.PgConnection.<init>( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.Driver.makeConnection( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.Driver.connect( ~[postgresql-42.5.3.jar:42.5.3]
        at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection( ~[c3p0-]
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection( ~[c3p0-]
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection( ~[c3p0-]
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource( ~[c3p0-]
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire( ~[c3p0-]
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess( ~[c3p0-]
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700( ~[c3p0-]
        at com.mchange.v2.resourcepool.BasicResourcePool$ ~[c3p0-]
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$ ~[mchange-commons-java-0.2.19.jar:0.2.19]
Caused by: Connection refused (Connection refused)
        at Method) ~[?:?]
        at ~[?:?]
        at ~[?:?]
        at ~[?:?]
        at ~[?:?]
        at ~[?:?]
        at org.postgresql.core.PGStream.createSocket( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.PGStream.<init>( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect( ~[postgresql-42.5.3.jar:42.5.3]
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl( ~[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 -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