Creating A GET Service

I Ran the sample curl commands given in creating a service example. I got Internal Server Error from “/mockbin.org”

Log.

curl -i -X GET \

–url http://localhost:8000/
–header ‘Host: example.com
HTTP/1.1 500 Internal Server Error
Date: Fri, 06 Apr 2018 11:00:27 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: kong/0.13.0

Hi, I just tried this:

curl -i -X POST \
  --url http://localhost:8001/services/ \
  --data 'name=example-service' \
  --data 'url=http://mockbin.org'
curl -i -X POST \
  --url http://localhost:8001/services/example-service/routes \
  --data 'hosts[]=example.com'
curl -i -X GET \
  --url http://localhost:8000/ \
  --header 'Host: example.com'

And it worked as expected. Did you get anything in your <kong-prefix>/logs/error.log?

Hi , I checked for a log file in /etc/kong folder. I did not see a error log file.
I am using Ubuntu 16.

Hi , I found the log file.

2018/04/05 12:41:56 [emerg] 5428#0: host not found in set_real_ip_from “none” in /usr/local/kong/nginx-kong.conf:71
2018/04/05 14:33:52 [emerg] 11972#0: host not found in set_real_ip_from “none” in /usr/local/kong/nginx-kong.conf:71
2018/04/05 14:54:53 [emerg] 13332#0: host not found in set_real_ip_from “none” in /usr/local/kong/nginx-kong.conf:71
2018/04/05 14:55:54 [emerg] 13413#0: host not found in set_real_ip_from “none” in /usr/local/kong/nginx-kong.conf:71
2018/04/05 14:58:36 [emerg] 13583#0: SSL_CTX_load_verify_locations("/usr/local/kong/none") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/usr/local/kong/none’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib)
2018/04/05 15:11:06 [emerg] 14436#0: SSL_CTX_load_verify_locations("/usr/local/kong/none") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/usr/local/kong/none’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib)
2018/04/05 15:40:57 [emerg] 16269#0: SSL_CTX_load_verify_locations("/usr/local/kong/none") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/usr/local/kong/none’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib)
2018/04/05 15:44:37 [emerg] 16528#0: SSL_CTX_load_verify_locations("/usr/local/kong/none") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/usr/local/kong/none’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib)
2018/04/05 15:47:52 [emerg] 16757#0: SSL_CTX_load_verify_locations("/usr/local/kong/none") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/usr/local/kong/none’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib)
2018/04/05 15:57:04 [notice] 17497#0: using the “epoll” event method
2018/04/05 15:57:04 [notice] 17497#0: openresty/1.13.6.1
2018/04/05 15:57:04 [notice] 17497#0: built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
2018/04/05 15:57:04 [notice] 17497#0: OS: Linux 4.13.0-1012-azure
2018/04/05 15:57:04 [notice] 17497#0: getrlimit(RLIMIT_NOFILE): 1024:1048576
2018/04/05 15:57:04 [notice] 17513#0: start worker processes
2018/04/05 15:57:04 [notice] 17513#0: start worker process 17514
2018/04/05 15:57:04 [notice] 17513#0: start worker process 17515
2018/04/05 16:57:04 [error] 17514#0: *8759 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8761 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8763 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8765 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8767 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8769 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8771 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8773 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8775 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8777 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8779 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8781 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 16:57:04 [error] 17514#0: *8755 [lua] reports.lua:49: log(): [reports] could not set peer name for UDP socket: [toip() name lookup failed]: dns lookup pool exceeded retries (1): failed to receive reply from UDP server 127.0.0.1:53: connection refused, context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17541 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17543 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17545 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17547 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17549 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17551 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17553 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17555 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17557 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17559 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17561 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17563 recv() failed (111: Connection refused), context: ngx.timer
2018/04/05 17:57:04 [error] 17515#0: *17538 [lua] reports.lua:49: log(): [reports] could not set peer name for UDP socket: [toip() name lookup failed]: dns lookup pool exceeded retries (1): failed to receive reply from UDP server 127.0.0.1:53: connection refused, context: ngx.timer
2018/04/05 18:57:04 [error] 17514#0: *26321 recv() failed (111: Connection refused), context: ngx.timer

How have you configured your trusted_ips configuration value? It looks like you have set it to none, try to change that to NONE (not sure if that is the reason, but at least worth to try):

I did not change anything from default kong.conf folder other than DB password.

Can you also display your:
/usr/local/kong/nginx-kong.conf

Does it say something like:

    real_ip_header     X-Real-IP;
    real_ip_recursive  off;
    set_real_ip_from   none;

I can do that with:

KONG_TRUSTED_IPS=none ./bin/kong prepare --vv

But I cannot with:

KONG_TRUSTED_IPS= ./bin/kong prepare --vv

Then I only get:

    real_ip_header     X-Real-IP;
    real_ip_recursive  off;

Have you used this file as a base for your config file?

Can you display your kong.conf too? And I stand corrected, don’t use NONE or none or other placeholders in your configs. Just don’t define them. Placeholders are only used for defaults:
https://github.com/Kong/kong/blob/master/kong/templates/kong_defaults.lua (don’t do anything to that)

I just made only one change to the conf file. added my password to the PostgresSQL database

#------------------------------------------------------------------------------

DATASTORE

#------------------------------------------------------------------------------

Kong will store all of its data (such as APIs, consumers and plugins) in

either Cassandra or PostgreSQL.

All Kong nodes belonging to the same cluster must connect themselves to the

same database.

#database = postgres # Determines which of PostgreSQL or Cassandra
# this node will use as its datastore.
# Accepted values are postgres and
# cassandra.

#pg_host = 127.0.0.1 # The PostgreSQL host to connect to.
#pg_port = 5432 # The port to connect to.
#pg_user = kong # The username to authenticate if required.
#pg_password = pwd # The password to authenticate if required.
#pg_database = kong # The database name to connect to.

#pg_ssl = off # Toggles client-server TLS connections
# between Kong and PostgreSQL.

#pg_ssl_verify = off # Toggles server certificate verification if
# pg_ssl is enabled.
# See the lua_ssl_trusted_certificate
# setting to specify a certificate authority.

#cassandra_contact_points = 127.0.0.1 # A comma-separated list of contact
# points to your cluster.

#cassandra_port = 9042 # The port on which your nodes are listening
# on. All your nodes and contact points must
# listen on the same port.

#cassandra_keyspace = kong # The keyspace to use in your cluster.

#cassandra_timeout = 5000 # Defines the timeout (in ms), for reading
# and writing.

#cassandra_ssl = off # Toggles client-to-node TLS connections
# between Kong and Cassandra.

#cassandra_ssl_verify = off # Toggles server certificate verification if
# cassandra_ssl is enabled.
# See the lua_ssl_trusted_certificate
# setting to specify a certificate authority.

#cassandra_username = kong # Username when using the
# PasswordAuthenticator scheme.

#cassandra_password = # Password when using the
# PasswordAuthenticator scheme.

#cassandra_consistency = ONE # Consistency setting to use when reading/
# writing to the Cassandra cluster.

#cassandra_lb_policy = RoundRobin # Load balancing policy to use when
# distributing queries across your Cassandra
# cluster.
# Accepted values are RoundRobin and
# DCAwareRoundRobin.
# Prefer the later if and only if you are
# using a multi-datacenter cluster.

#cassandra_local_datacenter = # When using the DCAwareRoundRobin load
# balancing policy, you must specify the name
# of the local (closest) datacenter for this
# Kong node.

#cassandra_repl_strategy = SimpleStrategy # When migrating for the first time,
# Kong will use this setting to
# create your keyspace.
# Accepted values are
# SimpleStrategy and
# NetworkTopologyStrategy.

#cassandra_repl_factor = 1 # When migrating for the first time, Kong
# will create the keyspace with this
# replication factor when using the
# SimpleStrategy.

#cassandra_data_centers = dc1:2,dc2:3 # When migrating for the first time,
# will use this setting when using the
# NetworkTopologyStrategy.
# The format is a comma-separated list
# made of <dc_name>:<repl_factor>.

#cassandra_schema_consensus_timeout = 10000 # Defines the timeout (in ms) for
# the waiting period to reach a
# schema consensus between your
# Cassandra nodes.
# This value is only used during
# migrations.

I got your point, I just commented db password attribute and provided the password. Other attributes I left as it is.

@maybalas, did you get it running? I am still missing your:

/usr/local/kong/nginx-kong.conf

Check that it doesn’t have:

set_real_ip_from   none;

The error you posted somehow referred to that. Not sure if it is really about that.

Hi there, I am currently facing the same error. I did the following requests.

Both 1st & 2nd requests returned a 201 response but the third request returned the following

HTTP/1.1 500 Internal Server Error
Date: Wed, 29 Apr 2020 08:32:13 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Content-Length: 42
X-Kong-Response-Latency: 6
Server: kong/2.0.3

{“message”:“An unexpected error occurred”}

Here is the error log that I have.

2020/04/29 16:32:13 [crit] 8253#0: *100388 connect() failed (22: Invalid argument), context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:8090
2020/04/29 16:32:13 [crit] 8253#0: *100391 connect() failed (22: Invalid argument), context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:8090
2020/04/29 16:32:13 [crit] 8253#0: *100394 connect() failed (22: Invalid argument), context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:8090
2020/04/29 16:32:13 [crit] 8253#0: *100397 connect() failed (22: Invalid argument), context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:8090
2020/04/29 16:32:13 [crit] 8253#0: *100400 connect() failed (22: Invalid argument), context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:8090
2020/04/29 16:32:13 [crit] 8253#0: *100403 connect() failed (22: Invalid argument), context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:8090
2020/04/29 16:32:13 [error] 8253#0: *100387 [lua] balancer.lua:921: execute(): DNS resolution failed: dns lookup pool exceeded retries (1): failed to create a resolver: failed to set peer name: invalid argument. Tried: ["(short)mockbin.org:(na) - cache-miss",“mockbin.org:33 - cache-miss/scheduled/try 1 error: failed to create a resolver: failed to set peer name: invalid argument/scheduled/try 2 error: failed to create a resolver: failed to set peer name: invalid argument/dns lookup pool exceeded retries (1): failed to create a resolver: failed to set peer name: invalid argument”,“mockbin.org:1 - cache-miss/scheduled/try 1 error: failed to create a resolver: failed to set peer name: invalid argument/scheduled/try 2 error: failed to create a resolver: failed to set peer name: invalid argument/dns lookup pool exceeded retries (1): failed to create a resolver: failed to set peer name: invalid argument”,“mockbin.org:5 - cache-miss/scheduled/try 1 error: failed to create a resolver: failed to set peer name: invalid argument/scheduled/try 2 error: failed to create a resolver: failed to set peer name: invalid argument/dns lookup pool exceeded retries (1): failed to create a resolver: failed to set peer name: invalid argument”], client: 127.0.0.1, server: kong, request: “GET / HTTP/1.1”, host: “example.com

Does anyone know how I can get rid of this error?