How to start Kong on Ubuntu 18.04?

I am newbee here. I installed Kong on Ubuntu 18.04

kong start -v /etc/kong/kong.conf.default
2019/04/19 11:39:07 [verbose] Kong: 1.1.0
2019/04/19 11:39:07 [verbose] no config file found at /etc/kong/kong.conf
2019/04/19 11:39:07 [verbose] no config file found at /etc/kong.conf
2019/04/19 11:39:07 [verbose] no config file, skip loading
2019/04/19 11:39:07 [verbose] prefix in use: /usr/local/kong
Error:
/usr/local/share/lua/5.1/kong/cmd/start.lua:30: [PostgreSQL error] failed to retrieve server_version_num: connection refused
stack traceback:
[C]: in function ‘assert’
/usr/local/share/lua/5.1/kong/cmd/start.lua:30: in function ‘cmd_exec’
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
[C]: in function ‘xpcall’
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
/usr/local/bin/kong:7: in function ‘file_gen’
init_worker_by_lua:48: in function <init_worker_by_lua:46>
[C]: in function ‘xpcall’
init_worker_by_lua:55: in function <init_worker_by_lua:53>

My /etc/kong/ jhas only default file. How to start Kong in a proper manner?

It seems like you don’t have Postgres running locally.
Please install and start Postgres on your machine and configure Kong to talk to it or use the dbless mode in Kong which doesn’t require a database.

I have postgres

postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------±---------±---------±------------±------------±----------------------
kong | kong | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
mydb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres

My datstore section of kong.conf

database = postgres

pg_host = 127.0.0.1 # Host of the Postgres server.
pg_port = 5432 # Port of the Postgres server.
pg_timeout = 5000 # Defines the timeout (in ms), for connecting,

pg_user = kong # Postgres user.
pg_password = mysecretpass # Postgres user’s password.
pg_database = kong # The database name to connect to.

Anyway

kong start -v /etc/kong/kong.conf
2019/04/19 18:37:15 [verbose] Kong: 1.1.0
2019/04/19 18:37:15 [verbose] reading config file at /etc/kong/kong.conf
2019/04/19 18:37:15 [verbose] prefix in use: /usr/local/kong
Error:
/usr/local/share/lua/5.1/kong/cmd/start.lua:30: [PostgreSQL error] failed to retrieve server_version_num: FATAL: password authentication failed for user “kong”
stack traceback:
[C]: in function ‘assert’
/usr/local/share/lua/5.1/kong/cmd/start.lua:30: in function ‘cmd_exec’

That seems like an authentication problem as the logs show.
Please ensure that “kong” user can actually authenticate with your password.
You could do psql -U kong to verify your password.

It seems so.

psql -U kong
psql: FATAL: Peer authentication failed for user “kong”

Have you create a kong role in psql?

You could do so:

# Create Postgres role and databases
psql -U postgres <<EOF
\x
CREATE ROLE kong;
ALTER ROLE kong WITH login;
CREATE DATABASE kong OWNER kong;
EOF

Look at my var/log/postgresql

2019-04-19 21:01:04.130 CEST [21160] kong@kong LOG: provided user name (kong) and authenticated user name (miki) do not match
2019-04-19 21:01:04.130 CEST [21160] kong@kong FATAL: Peer authentication failed for user “kong”
2019-04-19 21:01:04.130 CEST [21160] kong@kong DETAIL: Connection matched pg_hba.conf line 90: “local all all peer”

My desktop username is miki

@MilenkoM omitting the pg password.