# Knife client list unexpected error

**URL:** <https://discourse.chef.io/t/knife-client-list-unexpected-error/22545>\
**Category:** Chef Automate\
**Created:** [October 31, 2023, 7:34pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545 "2023-10-31T19:34:21Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 7:34pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/1 "2023-10-31T19:34:21Z")

</div>

Hi, I've been trying to set up a basic Chef Automate with Chef Infra install, following both the docs on the site and Chef's YouTube videos.  
Everything appears to work as expected up until I try to do a 'knife client list' after adding the user .pem file, fetching the server certificate etc which fails with a NoMethodError, apparently sending HTML instead of JSON.  
Not sure what else to try, I may attempt a standalone install of Chef Infra rather than the one deployed via Chef Automate if that might make a difference.  
I am also attempting this in a cloud provider environment, and it doesn't matter whether I use a workstation VM or my local workstation w VPN access, the result is the same. I may try a local setup with VMs on my local workstation to rule out any provider issues

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [October 31, 2023, 8:22pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/2 "2023-10-31T20:22:49Z")

</div>

what version of chef-workstation are you using?

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 8:25pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/4 "2023-10-31T20:25:33Z")

</div>

21.10.640 on a linux workstation  
23.7.1042 on a Macbook

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 8:32pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/5 "2023-10-31T20:32:17Z")

</div>

Also I've noticed among other things I don't have an /etc/opscode/chef-server.rb for example - the directory doesn't even exist. Should it if the Chef Infra install was done via chef-automate deploy?

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [October 31, 2023, 8:48pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/6 "2023-10-31T20:48:37Z")

</div>

automate is running habitat under the hood and habitat locates all files into /hab directory as chroot like environment.

make sure you have dns entry and fqdn defined in config. After install in your ~/.chef folder you'll need a config pointing to the chef-server-url with path to org name, your users.pem file, and network conectivity to chef-server/automate. then you'll need to run `knife ssl fetch https://fqdn-to-chef-server.com`. Then `knife status` should work.

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 9:11pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/8 "2023-10-31T21:11:47Z")

</div>

The ssl fetch and ssl check work, knife status gives 405 Error Not Allowed  
knife config show everything looks correct , chef\_server\_url is https: path to my org name

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [October 31, 2023, 9:26pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/9 "2023-10-31T21:26:19Z")

</div>

did you run the command to add the user to the chef-server org? [Install Chef Infra Server With Automate](https://docs.chef.io/automate/infra_server/#set-up-the-chef-infra-server)

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 9:30pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/10 "2023-10-31T21:30:17Z")

</div>

yes and the association user is a user created with the user-create command, the user's .pem file is copied to ~/.chef on the workstation, in the credentials file the client\_name is the username

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [October 31, 2023, 9:36pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/11 "2023-10-31T21:36:11Z")

</div>

That is all correct then. Otherwise try adding -VVV to knife command to see if it gives more info. Maybe create a different test org and add the user and see if that one works, possibly even a new user and add to both orgs and test. Throwing out Ideas to narrow down possible issue with org or user created.

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 10:06pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/12 "2023-10-31T22:06:07Z")

</div>

this is the output of knife status -VVV. It also says it's doing a POST request which seems odd  
TRACE: ---- HTTP Response Body ----  
TRACE:

405 Not Allowed
# 405 Not Allowed

* * *
nginx

TRACE: ---- End HTTP Response Body -----  
TRACE: ---- HTTP Request Body ----  
TRACE: {"name":["name"],"ipaddress":["ipaddress"],"ohai\_time":["ohai\_time"],"cloud":["cloud"],"run\_list":["run\_list"],"platform":["platform"],"platform\_version":["platform\_version"],"chef\_environment":["chef\_environment"]}  
TRACE: ---- End HTTP Request Body ----  
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle\_response  
TRACE: Content-Length validated correctly.  
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle\_response  
TRACE: Expected JSON response, but got content-type 'text/html'  
TRACE: Response body contains:

405 Not Allowed
# 405 Not Allowed

* * *
nginx

TRACE: Initiating POST to [https://chef-test](https://chef-test).(edited out my domain)

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [October 31, 2023, 10:10pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/13 "2023-10-31T22:10:30Z")

</div>

Here's the output from knife client list -VVV

knife client list -VVV  
INFO: Using configuration from /home/testuser/chef-repo/.chef/config.rb  
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle\_request  
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle\_request  
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle\_request  
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle\_request  
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle\_request  
TRACE: Signing the request as test\_chef  
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle\_request  
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle\_request  
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle\_request  
TRACE: Initiating GET to [https://chef-test](https://chef-test).(my test domain)/clients  
TRACE: ---- HTTP Request Header Data: ----  
TRACE: Accept: application/json  
TRACE: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3  
TRACE: X-Ops-Server-API-Version: 1  
TRACE: X-OPS-SIGN: algorithm=sha1;version=1.1;  
TRACE: X-OPS-USERID: test\_chef  
TRACE: X-OPS-TIMESTAMP: 2023-10-31T22:06:44Z  
TRACE: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=  
TRACE: X-OPS-AUTHORIZATION-1: F1VZBW7Sw204UFXbqMgoErogS5UAHMsz0XjZnpIu9vDkFKphZE+XsCAE0lMX  
TRACE: X-OPS-AUTHORIZATION-2: Vq/6v0l08dyJ83BthSgKIz/J6KQAIEzu/rcOgENwUCACqw8whaZ1Y37dmyNo  
TRACE: X-OPS-AUTHORIZATION-3: F0zYnipyVktrBxXxZJp0gQ/c13f1oH7sS1y58F/ImgWIwnNfDRGmo3nTaVm5  
TRACE: X-OPS-AUTHORIZATION-4: CHqYC7Bv/6/E/8DS2MyGuvtx7Pv1CM1SBEcOWhzD6njzD/SfSy8rVaiifLT1  
TRACE: X-OPS-AUTHORIZATION-5: Rs+yu4AbPQRIvrdrJL/51YoSx3R2JOU0TgtT7tBpOKCtOoXaOrU1Pz9b/Us4  
TRACE: X-OPS-AUTHORIZATION-6: 6akVSOzPoY/QmFdw4bibAqRWq0NyjqitDolAdoI5Iw==  
TRACE: HOST: chef-test.(my test domain):443  
TRACE: X-REMOTE-REQUEST-ID: ff8f90c4-391e-48e4-a15d-ace946e99add  
TRACE: ---- End HTTP Request Header Data ----  
TRACE: ---- HTTP Status and Header Data: ----  
TRACE: HTTP 1.1 200 OK  
TRACE: date: Tue, 31 Oct 2023 22:06:44 GMT  
TRACE: content-type: text/html  
TRACE: content-length: 2466  
TRACE: connection: close  
TRACE: last-modified: Thu, 12 Oct 2023 06:19:46 GMT  
TRACE: etag: "65279002-9a2"  
TRACE: strict-transport-security: max-age=63072000; includeSubDomains  
TRACE: accept-ranges: bytes  
TRACE: x-frame-options: sameorigin  
TRACE: cache-control: private  
TRACE: x-xss-protection: 1; mode=block  
TRACE: x-content-type-options: nosniff  
TRACE: ---- End HTTP Status/Header Data ----  
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle\_response  
TRACE: Content-Length validated correctly.  
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle\_response  
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle\_response  
TRACE: Expected JSON response, but got content-type 'text/html'

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [November 1, 2023, 3:43pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/14 "2023-11-01T15:43:57Z")

</div>

output from tailing /var/log/messages on the Chef Automate / Infra server when running knife org list from the workstation:

Nov 1 15:42:12 chef-test hab[26420]: automate-ui.default(O): - [01/Nov/2023:15:42:12 +0000] "GET /infrastructure/chef-servers/chef-test/organizations HTTP/1.1" 200 "0.000" 2466 "-" "Chef Infra Client Knife/17.6.18 (ruby-3.0.2-p107; ohai-17.6.0; x86\_64-linux; +https://chef.io)" "-" "-" "-" 1041  
Nov 1 15:42:12 chef-test hab[26420]: automate-load-balancer.default(O): - [01/Nov/2023:15:42:12 +0000] "GET /infrastructure/chef-servers/chef-test/organizations HTTP/1.1" 200 "0.000" 2466 "-" "Chef Infra Client Knife/17.6.18 (ruby-3.0.2-p107; ohai-17.6.0; x86\_64-linux; +https://chef.io)" "127.0.0.1:10161" "200" "0.000" 1105  
Nov 1 15:42:13 chef-test hab[26420]: automate-ui.default(O): - [01/Nov/2023:15:42:13 +0000] "HEAD / HTTP/1.1" 200 "0.000" 0 "-" "curl/7.79.1" "-" "-" "-" 82  
Nov 1 15:42:16 chef-test hab[26420]: automate-postgresql.default(O): 2023-11-01 15:42:16 GMT [1809994]: [1-1] user=,db=,client= (0:00000)LOG: automatic analyze of table "chef\_cereal\_service.public.cereal\_workflow\_instances" system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s  
Nov 1 15:42:21 chef-test hab[26420]: automate-cs-ocid.default(O): I, [2023-11-01T15:42:21.253405 #37720] INFO -- : Started GET "/id/signin" for 127.0.0.1 at 2023-11-01 15:42:21 +0000  
Nov 1 15:42:21 chef-test hab[26420]: automate-cs-ocid.default(O): I, [2023-11-01T15:42:21.254200 #37720] INFO -- : Processing by SessionsController#new as _/_  
Nov 1 15:42:21 chef-test hab[26420]: automate-cs-ocid.default(O): I, [2023-11-01T15:42:21.255271 #37720] INFO -- : Rendered sessions/new.html.erb within layouts/application (Duration: 0.5ms | Allocations: 308)  
Nov 1 15:42:21 chef-test hab[26420]: automate-cs-ocid.default(O): I, [2023-11-01T15:42:21.256891 #37720] INFO -- : Rendered layout layouts/application.html.erb (Duration: 2.1ms | Allocations: 1651)  
Nov 1 15:42:21 chef-test hab[26420]: automate-cs-ocid.default(O): I, [2023-11-01T15:42:21.257052 #37720] INFO -- : Completed 200 OK in 3ms (Views: 2.5ms | Allocations: 1929)

---

<div class="post-metadata">

**Author:** ![moffman77](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@moffman77](https://discourse.chef.io/u/moffman77)\
**Post date:** [November 1, 2023, 7:18pm UTC](https://discourse.chef.io/t/knife-client-list-unexpected-error/22545/15 "2023-11-01T19:18:48Z")

</div>

Argh, the problem was just the chef\_server\_url - I was including the entire path to the org i.e. [https://myserver.mydomain/infrastructure/chef-servers/myserver/organizations/myorg](https://myserver.mydomain/infrastructure/chef-servers/myserver/organizations/myorg) and not just [https://myserver.mydomain/organizations/myorg](https://myserver.mydomain/organizations/myorg)  
the correct path is shown in the example credentials / config.rb's but I didn't see it until now
