Installing postgres for Codacy Enterprise

Postgres Installation Guide

Codacy requires a working installation of Postgres to work. Depending on the number of projects you are running you might need different requirements.

Recommended specs:
4 cores CPU
Minimum 100 GB+ Hard Drive - this will depend on the number of projects you have. For tailored information, please, contact us at 

If you already have a Postgres installation, jump directly to step 1.3.

Postgres Version

Codacy officially supports Postgres versions 9.3 and 9.4. Codacy requires 'UTF-8' encoding. Make sure that your database character set is correctly configured. For more information see


1 - Postgres

Here are some quick steps to have a running Postgres installation on Ubuntu 16.04. 


1.1 - Configure system locale to support UTF-8

Before installing postgres, you'll need to make sure your system locale is configured to use UTF-8. You can check your current locale by running:


You can change your locale to a UTF-8 variant by running:

update-locale LANG=en_US.UTF-8


1.2 - Install postgres

First, ensure that you install postgres 9.4 following the instructions described here.


1.3 - Run postgres

Installing PostgreSQL on Ubuntu should start the service by default. However, let's check that it's running with:

sudo systemctl status postgresql

If PostgreSQL is running, you'll see output that includes the text Active: active (exited).

If you see Active: inactive (dead), start the PostgreSQL service using the following command:

sudo systemctl start postgresql

PostgreSQL also needs to be enabled to start on reboot. Do that with this command:

sudo systemctl enable postgresql


1.4 - Allow external connections

In order to access PostgreSQL from a different machine, you need to do additional configurations to allow external connections. 

Using Nano (or vim/emacs/other), edit your postgresql.conf file. We're specifically looking for a line that says listen_addresses. We're going to modify where PostgreSQL is listening on.

# /etc/postgresql/9.4/main/postgresql.conf


# - Connection Settings -

listen_addresses = '*'


Next we're going to edit our pg_hba.conf file and configure it to allow remote connections. At the very end of the file, add the following line:

# /etc/postgresql/9.4/main/pg_hba.conf

host all all md5

This is a rule that basically tells PostgreSQL to allow anyone to access the instance, as long as they have proper credentials.

If you want to whitelist your IP only, you can use your network/mask instead of (for example:

Note: Despite being not recommended, if you're running postgres on the same machine where codacy is and you want to whitelist just the codacy's IP address, you have to whitelist a range of IP addresses because codacy runs inside docker and it won't have always the same IP address inside the docker network. Therefore, you should first obtain the address of the docker network interface with an ifconfig and then whitelist the ip addresses according to it (for example,


Finally, restart postgres:

sudo service postgresql restart

Note: Actual file locations may change depending on what package and operating system you use. Just google where to find your postgres conf file and you'll be fine.


1.5 - Creating user

It is advised that you create a particular user that will only be able to access Codacy specific databases. To do so, using the psql shell, create a user:

sudo -u postgres psql


You can change the user/password to suit your security needs.

Make sure that you can connect to the Postgres database using the newly created user. For additional settings, follow the steps in the Postgres documentation.


Additional topics

Connecting psql Client Using the Google Cloud SQL Proxy Docker Image

If you are connecting to your postgres instance through a docker container proxy, we recommend that you configure the following:

  • Make sure your postgres docker container is configured with --restart always
  • In the Codacy control panel, the "Database hostname" option should be set with the IP address or DNS of the Codacy instance itself


Have more questions? Submit a request


Please sign in to leave a comment.