Beginner: After initial set up "unexpected error occured" (no logs)

Hi there, I want to start using Kong and so I went through the first couple of steps in the official quickstart guide for OSX. I’m trying to run kong with postgres. I created a postgres user and database no problem, then started kong and created a service and route, however, when I send a query via kong for that route I get an error message. I’ve detailed the error below and what I’ve tested so far, I’d really be grateful if anyone has any advice on how to debug this? Or what I might have done wrong in setting up? Thank you!

The problem comes when I actually try to execute a request with kong (no problem with admin):

$ curl -i -X GET \
  --url http://localhost:8000/ \
  --header 'Host: example.com'

Results in:

HTTP/1.1 500 Internal Server Error
Date: Mon, 14 Sep 2020 09:16:48 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Content-Length: 42
X-Kong-Response-Latency: 28
Server: kong/2.1.3

{"message":"An unexpected error occurred"}

Also I can’t seem to get any logs to try and debug this rather terse error message. The folder usr/local/kong does not exist. I also tried installing a syslog addon to try and get logs but again the logs are not being output in the /var/log/ folder.

If I query kong’s admin url directly for the service everything seems to be set up ok I think.

{"host":"mockbin.org",
"id":"48261135-8aed-4e04-a1ad-3b8ed25b82ee",
"protocol":"http",
"read_timeout":60000,
"tls_verify_depth":null,
"port":80,"updated_at":1599900991,
"ca_certificates":null,
"created_at":1599900991,
"connect_timeout":60000,
"write_timeout":60000,
"name":"example-service",
"retries":5,
"path":null,
"tls_verify":null,
"tags":null,
"client_certificate":null}

And the same for the route

{"next":null,
"data":[{"id":"cd24b4f3-aa30-45f6-8ec5-7156fe5856b9",
"path_handling":"v0",
"paths":null,
"destinations":null,
"headers":null,
"protocols":["http","https"],
"created_at":1599901530,
"snis":null,
"service":{"id":"48261135-8aed-4e04-a1ad-3b8ed25b82ee"},
"name":null,
"strip_path":true,
"preserve_host":false,
"regex_priority":0,
"updated_at":1599901530,
"sources":null,
"methods":null,
"https_redirect_status_code":426,
"hosts":["example.com"],
"tags":null}]}

YOU CAN’T CURL KONG on 8000 since it will not accessible for you. if you wanna make sure that either kong is running then you should curl
curl -i -X GET
–url http://localhost:8001/
–header ‘Host: example.com

Thank you for your reply. I’m sorry if I’m misunderstanding, but why is port 8000 not accessible? From the official kong tutorial, it says that:

Kong handles proxy requests on port :8000 :

And my understanding was that after I had set up my services and routes send a cURL to port 8000 would act would proxy that request through kong based on the request header. Indeed when I change the port to 8001 I still get configuration information for the route rather than the actual data back from the API but proxied through kong.

Perhaps I haven’t understood the concept properly, but based on what I’ve read in the quick start docs I don’t think I understand why the request would be causing an error.

@okpd Hi and welcome!

Ouch. Well, to investigate HTTP 5xx errors (which in HTTP are server errors, and in the case of 500, most likely a Lua runtime error) one needs to have a look at the proxy_error_logs (since the errors happens on the proxy port 8000). By default, this file is in /usr/local/kong/logs/error.log.

In there, you should see at least one such line around the time of the request (refer to the Date header in the HTTP response):

2020/09/14 09:16:48 [error] 73818#0: *26008196135 lua entry thread aborted: ...
stack traceback:
coroutine 0:
/usr/local/share/lua/5.1/kong/file.lua: in function '...'
/usr/local/share/lua/5.1/kong/file.lua: in function '...'
/usr/local/share/lua/5.1/kong/file.lua: in function '...'
access_by_lua(nginx.conf:124):2: in main chunk,

We should be looking for any other [error] entry in this file as well (or higher priority entries if any). This can start giving you an understanding of the underlying issue. If not, feel free to open a GitHub issue in order to report the bug if you believe it is an issue with Kong.

Hi @thibaultcha,

Thank you very much for your reply.

Unfortunately, the folder usr/local/kong/logs/ doesn’t exist for me. I tried to creating it manually with an empty error.log file and running kong again but the file just remains empty. So maybe I should raise a Github issue? As currently, it doesn’t seem like I’ve got any way of debugging the error.

The proxy_error_logs path is prefixed by the prefix configuration value. Your error logs will be at <prefix>/<proxy_error_logs>.

Unless you are running within a container, in which case proxy_error_logs could be set to send logs to stdout or stderr, depending on your configuration.

You can also request the Admin API’s / (root) endpoint and see what the value for these configuration properties is.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ