Hello,
In the future, please paste the exact error message and configuration. The question by itself does not help anyone help you. What follows is a guess due to lack of information.
It seems you're performing a function (perhaps ngx.location.capture) in a context that can not run it. There is no troubleshooting it. It is an operation that is unsupported.
An example might be, ngx.location.capture inside of an init_by_lua block. The reason is ngx.location capture requires an internal request object to function. A request object like this is unavailable at the init phase.