Issue
I tried to install using the instructions available on https://docs.konghq.com/install/ubuntu/ and also using snap store but I get the same error. I don't know if it's relevant or not but I am using postgres-12.2 which comes pre-installed with Ubuntu-20.04. The directory structure in postgres-12.2 is different from the earlier ones.
error: cannot perform the following tasks:
- Run install hook of "kong" snap if present (run hook "install":
-----
The files belonging to this database system will be owned by user "snap_daemon".
This user must also own the server process.
The database cluster will be initialized with locale "C.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory /var/snap/kong/172/postgresql/10/main ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Kolkata
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
/snap/kong/172/usr/lib/postgresql/10/bin/pg_ctl -D /var/snap/kong/172/postgresql/10/main -l logfile start
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/snap/kong/common/sockets/.s.PGSQL.5432"?
-----)```
[1]: https://i.stack.imgur.com/2pzKn.png
Solution
Finally, it was done after a lot of research and endless tries. If you face the same issue, follow the following order(For Ubuntu 20.04 only):
Better not install using apt-get or snap(at least until a snap for Ubuntu 20.04 is available). Install using the .deb package available at https://docs.konghq.com/install/ubuntu/#packages. After downloading the package, navigate to the Downloads folder in the terminal and run the following commands to install:
sudo apt-get install openssl libpcre3 procps perl
sudo dpkg -i kong-2.0.4.*.debDon't know what the first command is installing but it is suggested to do so as per the official documentation of KONG.
In another terminal, create a new user and database in postgres for KONG connectivity.
sudo -i -u postgres
psql
CREATE USER kong;
CREATE DATABASE kong OWNER kong;Back to the terminal where you were installing KONG. Try running the command:
sudo kong migrations bootstrap
If everything goes without a glitch, consider yourself lucky and go to step 5.
If there occurs an error at step 3 as:
Error: missing password, required for connect
, there's more work to be done.- Run the command:
kong check
- This should list an error as
[error] no file at: /etc/kong/kong.conf
. Create a file namedkong.conf
in the directory/etc/kong
and paste the contents available at https://github.com/Kong/kong/blob/master/kong.conf.default. - Thereafter, uncomment the lines which initialize the following variables: https://docs.konghq.com/2.0.x/configuration/#postgres-settings. If in step 2, you created user and database with different names, make sure to modify the credentials in the file
kong.conf
with your user(role) and database names.
[You may face trouble creating files and editing them at this step.]
- Run the command:
Run the command
sudo kong start
to verify the correct configuration. Open your browser and navigate to
http://localhost:8001
. If some page opens, KONG is correctly configured on your device. Go back to the terminal and stop KONG using the commandsudo kong stop
Answered By - Adarsh Kumar