Hello,
I followed this guide to install Kong 0.9.2 on Ubuntu 14.04 along with Postgres 9.5.4. It fails to start and throws the following error:
ubuntu@ip-172-31-14-202:~$ kong start -vv
2016/09/22 14:51:36 [verbose] no config file found at /etc/kong.conf
2016/09/22 14:51:36 [verbose] reading config file at /etc/kong/kong.conf
2016/09/22 14:51:36 [debug] admin_listen = "0.0.0.0:8001"
2016/09/22 14:51:36 [debug] anonymous_reports = true
2016/09/22 14:51:36 [debug] cassandra_consistency = "ONE"
2016/09/22 14:51:36 [debug] cassandra_contact_points = {"127.0.0.1"}
2016/09/22 14:51:36 [debug] cassandra_data_centers = {"dc1:2","dc2:3"}
2016/09/22 14:51:36 [debug] cassandra_keyspace = "kong"
2016/09/22 14:51:36 [debug] cassandra_port = 9042
2016/09/22 14:51:36 [debug] cassandra_repl_factor = 1
2016/09/22 14:51:36 [debug] cassandra_repl_strategy = "SimpleStrategy"
2016/09/22 14:51:36 [debug] cassandra_ssl = false
2016/09/22 14:51:36 [debug] cassandra_ssl_verify = false
2016/09/22 14:51:36 [debug] cassandra_timeout = 5000
2016/09/22 14:51:36 [debug] cassandra_username = "kong"
2016/09/22 14:51:36 [debug] cluster_listen = "0.0.0.0:7946"
2016/09/22 14:51:36 [debug] cluster_listen_rpc = "127.0.0.1:7373"
2016/09/22 14:51:36 [debug] cluster_profile = "wan"
2016/09/22 14:51:36 [debug] cluster_ttl_on_failure = 3600
2016/09/22 14:51:36 [debug] custom_plugins = {}
2016/09/22 14:51:36 [debug] database = "postgres"
2016/09/22 14:51:36 [debug] dnsmasq = true
2016/09/22 14:51:36 [debug] dnsmasq_port = 8053
2016/09/22 14:51:36 [debug] log_level = "notice"
2016/09/22 14:51:36 [debug] lua_code_cache = "on"
2016/09/22 14:51:36 [debug] lua_package_cpath = ""
2016/09/22 14:51:36 [debug] lua_package_path = "?/init.lua;./kong/?.lua"
2016/09/22 14:51:36 [debug] lua_ssl_verify_depth = 1
2016/09/22 14:51:36 [debug] mem_cache_size = "128m"
2016/09/22 14:51:36 [debug] nginx_daemon = "on"
2016/09/22 14:51:36 [debug] nginx_optimizations = true
2016/09/22 14:51:36 [debug] nginx_worker_processes = "auto"
2016/09/22 14:51:36 [debug] pg_database = "kong"
2016/09/22 14:51:36 [debug] pg_host = "127.0.0.1"
2016/09/22 14:51:36 [debug] pg_password = "******"
2016/09/22 14:51:36 [debug] pg_port = 5432
2016/09/22 14:51:36 [debug] pg_ssl = false
2016/09/22 14:51:36 [debug] pg_ssl_verify = false
2016/09/22 14:51:36 [debug] pg_user = "kong"
2016/09/22 14:51:36 [debug] prefix = "/usr/local/kong/"
2016/09/22 14:51:36 [debug] proxy_listen = "0.0.0.0:8000"
2016/09/22 14:51:36 [debug] proxy_listen_ssl = "0.0.0.0:8443"
2016/09/22 14:51:36 [debug] serf_path = "serf"
2016/09/22 14:51:36 [debug] ssl = true
2016/09/22 14:51:36 [verbose] prefix in use: /usr/local/kong
2016/09/22 14:51:36 [verbose] preparing nginx prefix directory at /usr/local/kong
2016/09/22 14:51:36 [verbose] saving serf identifier to /usr/local/kong/serf/serf.id
2016/09/22 14:51:36 [debug] searching for OpenResty 'resty' executable
2016/09/22 14:51:36 [debug] /usr/local/openresty/bin/resty -V: 'nginx version: openresty/1.9.15.1'
2016/09/22 14:51:36 [debug] found OpenResty 'resty' executable at /usr/local/openresty/bin/resty
2016/09/22 14:51:36 [verbose] saving serf shell script handler to /usr/local/kong/serf/serf_event.sh
2016/09/22 14:51:36 [verbose] SSL enabled, no custom certificate set: using default certificate
2016/09/22 14:51:36 [verbose] default SSL certificate found at /usr/local/kong/ssl/kong-default.crt
2016/09/22 14:51:36 [warn] ulimit is currently set to "1024". For better performance set it to at least "4096" using "ulimit -n"
2016/09/22 14:51:36 [verbose] running datastore migrations
2016/09/22 14:51:36 [verbose] could not start Kong, stopping services
2016/09/22 14:51:36 [verbose] leaving serf cluster
2016/09/22 14:51:37 [verbose] stopping dnsmasq at /usr/local/kong/pids/dnsmasq.pid
2016/09/22 14:51:37 [debug] sending signal to pid at: /usr/local/kong/pids/dnsmasq.pid
2016/09/22 14:51:37 [debug] no pid file at: /usr/local/kong/pids/dnsmasq.pid
2016/09/22 14:51:37 [verbose] stopped services
Error:
/usr/local/share/lua/5.1/kong/cmd/start.lua:41: /usr/local/share/lua/5.1/kong/cmd/start.lua:22: [postgres error] ERROR: function to_regclass(unknown) does not exist (8)
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/kong/cmd/start.lua:41: in function 'cmd_exec'
/usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:81>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:42>
/usr/local/bin/kong:13: in function 'file_gen'
init_worker_by_lua:38: in function <init_worker_by_lua:36>
[C]: in function 'pcall'
init_worker_by_lua:45: in function <init_worker_by_lua:43>
ubuntu@ip-172-31-14-202:~$
$ sudo apt-get update
$ sudo apt-get install netcat openssl libpcre3 dnsmasq procps perl
$ sudo dpkg -i kong-0.9.2.*.deb
Install Postgres
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install postgresql
Configured /etc/kong/kong.conf file with Postgres credentials, rest everything set to default values.
$ kong version
0.9.2
$ psql -V
psql (PostgreSQL) 9.5.4
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
@thibaultcha I also had the same problem in Vagrant with Ubuntu 12.04 (precise).
to_regclass() is supposed to be in Postgres 9.4+, I can't help much more beyond that.
What does this produce?
$ psql -U kong
psql (9.5.4)
Type "help" for help.
kong=> SELECT to_regclass('schema_migrations');
@thibaultcha I had this problem with 9.4 too. Maybe the problem is not to_regclass but to_regclass(unknown). Where does unknown come from?
@thibaultcha Resolved this issue. After some digging around, found out that postgres installed via default ubuntu repo installs 9.3 which was later upgraded to 9.5 through postgres's official repo. In doing so, both the versions of postgres were active.
$ psql -U kong
psql: FATAL: Peer authentication failed for user "kong"
$ sudo service postgresql status
9.3/main (port 5432): online
9.5/main (port 5433): online
Fix some anyone who gets stuck at this error:
$ sudo service postgresql stop
$ sudo rm -rf /etc/postgresql/9.3
$ sudo service postgresql start
* Starting PostgreSQL 9.5 database server [ OK ]
Now if you don't have password set for kong user, you will receive the following error
Error:
/usr/local/share/lua/5.1/kong/cmd/start.lua:41: /usr/local/share/lua/5.1/pgmoon-mashape/init.lua:239: missing password, required for connect
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/kong/cmd/start.lua:41: in function 'cmd_exec'
/usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:81>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/kong/cmd/init.lua:81: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:42>
/usr/local/bin/kong:13: in function 'file_gen'
init_worker_by_lua:38: in function <init_worker_by_lua:36>
[C]: in function 'pcall'
init_worker_by_lua:45: in function <init_worker_by_lua:43>
Run the following command in postgres to update the password and also update it in kong.conf file
postgres=# ALTER USER kong WITH password 'k0ng';
Kong should start now, to confirm you could run
$ curl --head -X GET localhost:8001/status
HTTP/1.1 200 OK
...
I was suspecting something like that indeed... Ok, glad it worked out! Thanks for documenting the resolution steps.
I also facing same problem.. Please give me clear solution to this issue..
I too facing same problem.. please let us know proper reason and solution for this issue ... Thanks in advance :)
Just Commenting Out pg_* solved my problem..
pg_user = kong
pg_password = kong
pg_database = kong
Just Removing Commenting From pg_* Prefixed variables in kong.conf file.. solved my problem..
pg_user = kong
pg_password = kong
pg_database = kong
I had the same problem with kong 0.10.0.. i went to /usr/local/share/lua/5.1/kong/templates/kong_defaults.lua and changed pssword=NONE to pssword=kong ..worked like a charm..i found this solution in here http://jingyan.baidu.com/article/f54ae2fc1308f31e92b84990.html
just created a new issue for these passwords being out of sync #2254
@latesh
I take your action , but meet this issue . i got the connection issues,
i use the sudo service postgresql status ,it shows online.

2017/08/22 11:36:37 [verbose] running datastore migrations
2017/08/22 11:36:37 [verbose] could not start Kong, stopping services
2017/08/22 11:36:37 [verbose] leaving serf cluster
2017/08/22 11:36:37 [verbose] stopping dnsmasq at /usr/local/kong/pids/dnsmasq.pid
2017/08/22 11:36:37 [debug] sending signal to pid at: /usr/local/kong/pids/dnsmasq.pid
2017/08/22 11:36:37 [debug] no pid file at: /usr/local/kong/pids/dnsmasq.pid
2017/08/22 11:36:37 [verbose] stopped services
Error:
/usr/local/share/lua/5.1/kong/cmd/start.lua:37: /usr/local/share/lua/5.1/kong/cmd/start.lua:18: [postgres error] connection refused
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/kong/cmd/start.lua:37: in function 'cmd_exec'
/usr/local/share/lua/5.1/kong/cmd/init.lua:89: in function
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/kong/cmd/init.lua:89: in function
/usr/local/bin/kong:15: in function 'file_gen'
init_worker_by_lua:38: in function
[C]: in function 'pcall'
init_worker_by_lua:45: in function
@channgli Kong uses a default port for Postgres as 5432, in your post above Postgres runs on 5433. Hence you get a connection refused error.
having said that, please do not comment on closed issues. For these type of issues you'd better check the email list or the Gitter channel.
Debian stretch /etc/postgresql/11/main/pg_hba.conf, initial value was peer, replace it with md5
# "local" is for Unix domain socket connections only
local all all md5
Most helpful comment
@thibaultcha Resolved this issue. After some digging around, found out that postgres installed via default ubuntu repo installs 9.3 which was later upgraded to 9.5 through postgres's official repo. In doing so, both the versions of postgres were active.
Fix some anyone who gets stuck at this error:
Now if you don't have password set for kong user, you will receive the following error
Run the following command in postgres to update the password and also update it in kong.conf file
Kong should start now, to confirm you could run