CLI Reference

The provided CLI (Command Line Interface) allows you to start, stop, and manage your Kong instances. The CLI manages your local node (as in, on the current machine).

If you haven’t yet, we recommend you read the configuration reference.

Global flags

All commands take a set of special, optional flags as arguments:

  • -h, --help: print the command’s help message
  • --v: enable verbose mode
  • --vv: enable debug mode (noisy)

Available commands

kong check

  1. Usage: kong check <conf>
  2. Check the validity of a given Kong configuration file.
  3. <conf> (default /etc/kong/kong.conf) configuration file

kong config

  1. Usage: kong config COMMAND [OPTIONS]
  2. Use declarative configuration files with Kong.
  3. The available commands are:
  4. init [<file>] Generate an example config file to
  5. get you started. If a filename
  6. is not given, ./kong.yml is used
  7. by default.
  8. db_import <file> Import a declarative config file into
  9. the Kong database.
  10. db_export [<file>] Export the Kong database into a
  11. declarative config file. If a filename
  12. is not given, ./kong.yml is used
  13. by default.
  14. parse <file> Parse a declarative config file (check
  15. its syntax) but do not load it into Kong.
  16. Options:
  17. -c,--conf (optional string) Configuration file.
  18. -p,--prefix (optional string) Override prefix directory.

Note: db_export is only supported with open-source Kong Gateway packages.


kong health

  1. Usage: kong health [OPTIONS]
  2. Check if the necessary services are running for this node.
  3. Options:
  4. -p,--prefix (optional string) prefix at which Kong should be running

kong hybrid

  1. Usage: kong hybrid COMMAND [OPTIONS]
  2. Hybrid mode utilities for Kong.
  3. The available commands are:
  4. gen_cert [<cert> <key>] Generate a certificate/key pair that is suitable
  5. for use in hybrid mode deployment.
  6. Cert and key will be written to
  7. './cluster.crt' and './cluster.key' inside
  8. the current directory unless filenames are given.
  9. Options:
  10. -d,--days (optional number) Override certificate validity duration.
  11. Default: 1095 days (3 years)

kong migrations

  1. Usage: kong migrations COMMAND [OPTIONS]
  2. Manage database schema migrations.
  3. The available commands are:
  4. bootstrap Bootstrap the database and run all
  5. migrations.
  6. up Run any new migrations.
  7. finish Finish running any pending migrations after
  8. 'up'.
  9. list List executed migrations.
  10. reset Reset the database.
  11. The `reset` command erases all of the data
  12. in Kong's database and deletes all of the schemas.
  13. migrate-community-to-enterprise Migrates Kong Community entities to
  14. Kong Enterprise in the default
  15. workspace.
  16. upgrade-workspace-table Outputs a script to be run on the db to
  17. upgrade the entity for 2.x workspaces
  18. implementation.
  19. reinitialize-workspace-entity-counters Resets the entity counters from the
  20. database entities.
  21. status Dump the database migration status in JSON format.
  22. Options:
  23. -y,--yes Assume "yes" to prompts and run
  24. non-interactively.
  25. -q,--quiet Suppress all output.
  26. -f,--force Run migrations even if database reports
  27. as already executed.
  28. With 'migrate-community-to-enterprise' it
  29. disables the workspace entities check.
  30. --db-timeout (default 60) Timeout, in seconds, for all database
  31. operations (including schema consensus for
  32. Cassandra).
  33. --lock-timeout (default 60) Timeout, in seconds, for nodes waiting on
  34. the leader node to finish running
  35. migrations.
  36. -c,--conf (optional string) Configuration file.
  37. -p,--prefix (optional string) Override prefix directory.
  38. --v verbose
  39. --vv debug

kong prepare

This command prepares the Kong prefix folder, with its sub-folders and files.

  1. Usage: kong prepare [OPTIONS]
  2. Prepare the Kong prefix in the configured prefix directory. This command can
  3. be used to start Kong from the nginx binary without using the 'kong start'
  4. command.
  5. Example usage:
  6. kong migrations up
  7. kong prepare -p /usr/local/kong -c kong.conf
  8. nginx -p /usr/local/kong -c /usr/local/kong/nginx.conf
  9. Options:
  10. -c,--conf (optional string) configuration file
  11. -p,--prefix (optional string) override prefix directory
  12. --nginx-conf (optional string) custom Nginx configuration template

kong quit

  1. Usage: kong quit [OPTIONS]
  2. Gracefully quit a running Kong node (Nginx and other
  3. configured services) in given prefix directory.
  4. This command sends a SIGQUIT signal to Nginx, meaning all
  5. requests will finish processing before shutting down.
  6. If the timeout delay is reached, the node will be forcefully
  7. stopped (SIGTERM).
  8. Options:
  9. -p,--prefix (optional string) prefix Kong is running at
  10. -t,--timeout (default 10) timeout before forced shutdown
  11. -w,--wait (default 0) wait time before initiating the shutdown

kong reload

  1. Usage: kong reload [OPTIONS]
  2. Reload a Kong node (and start other configured services
  3. if necessary) in given prefix directory.
  4. This command sends a HUP signal to Nginx, which will spawn
  5. new workers (taking configuration changes into account),
  6. and stop the old ones when they have finished processing
  7. current requests.
  8. Options:
  9. -c,--conf (optional string) configuration file
  10. -p,--prefix (optional string) prefix Kong is running at
  11. --nginx-conf (optional string) custom Nginx configuration template

kong restart

  1. Usage: kong restart [OPTIONS]
  2. Restart a Kong node (and other configured services like Serf)
  3. in the given prefix directory.
  4. This command is equivalent to doing both 'kong stop' and
  5. 'kong start'.
  6. Options:
  7. -c,--conf (optional string) configuration file
  8. -p,--prefix (optional string) prefix at which Kong should be running
  9. --nginx-conf (optional string) custom Nginx configuration template
  10. --run-migrations (optional boolean) optionally run migrations on the DB
  11. --db-timeout (default 60)
  12. --lock-timeout (default 60)

kong runner

  1. Usage: kong runner [file] [args]
  2. Execute a lua file in a kong node. the `kong` variable is available to
  3. reach the DAO, PDK, etc. The variable `args` can be used to access all
  4. arguments (args[1] being the lua filename being run).
  5. Example usage:
  6. kong runner file.lua arg1 arg2
  7. echo 'print("foo")' | kong runner

kong start

  1. Usage: kong start [OPTIONS]
  2. Start Kong (Nginx and other configured services) in the configured
  3. prefix directory.
  4. Options:
  5. -c,--conf (optional string) Configuration file.
  6. -p,--prefix (optional string) Override prefix directory.
  7. --nginx-conf (optional string) Custom Nginx configuration template.
  8. --run-migrations (optional boolean) Run migrations before starting.
  9. --db-timeout (default 60) Timeout, in seconds, for all database
  10. operations (including schema consensus for
  11. Cassandra).
  12. --lock-timeout (default 60) When --run-migrations is enabled, timeout,
  13. in seconds, for nodes waiting on the
  14. leader node to finish running migrations.

kong stop

  1. Usage: kong stop [OPTIONS]
  2. Stop a running Kong node (Nginx and other configured services) in given
  3. prefix directory.
  4. This command sends a SIGTERM signal to Nginx.
  5. Options:
  6. -p,--prefix (optional string) prefix Kong is running at

kong vault

  1. Usage: kong vault COMMAND [OPTIONS]
  2. Vault utilities for Kong.
  3. Example usage:
  4. TEST=hello kong vault get env/test
  5. The available commands are:
  6. get <reference> Retrieves a value for <reference>
  7. Options:
  8. -c,--conf (optional string) configuration file
  9. -p,--prefix (optional string) override prefix directory

kong version

  1. Usage: kong version [OPTIONS]
  2. Print Kong's version. With the -a option, will print
  3. the version of all underlying dependencies.
  4. Options:
  5. -a,--all get version of all dependencies