https://prefect.io logo
Title
a

André Bonatto

03/08/2021, 11:06 PM
Hi folks. When I try to create a tenant with the command "prefect server create-tenant --name default --slug default", I get 401 Client Error : Unauthorized for url: http://localhost:4200/graphql. Any idea what is causing this problem? Thank you very much!
k

Kyle Moon-Wright

03/08/2021, 11:23 PM
Hey @André Bonatto, I have not encountered this error when creating a tenant with Server before and I’m able to use that CLI command no problem. Are you running your Server instance on your local machine?
a

André Bonatto

03/08/2021, 11:24 PM
Hi Kyle. Yes, I'm trying to run on my laptop.
k

Kyle Moon-Wright

03/08/2021, 11:26 PM
What version of Prefect are you running? You can find out by running
prefect version
a

André Bonatto

03/08/2021, 11:28 PM
I believe it's the latest : 0.14.11
k

Kyle Moon-Wright

03/08/2021, 11:35 PM
Can you create a different tenant with the CLI? I ask because a default tenant/slug is created with those same arguments with a fresh Server instance (though there should be an explicit error for a duplicate). Does
prefect server create-tenant --name test-name --slug test-slug
create a new tenant for you or do you hit that 401?
a

André Bonatto

03/08/2021, 11:38 PM
Just tried that I received the same 401 Client Error
k

Kyle Moon-Wright

03/08/2021, 11:44 PM
Have you customized your Server deployment at all with a config.toml file or the like? It looks like we’re calling out to the default graphql endpoint, which may not work with custom deployments
This thread has some detail on a similar issue they encountered and had to update their config for Server.
a

André Bonatto

03/08/2021, 11:46 PM
I didn't change nothing, I was just following the tutorial. Thanks for the thread. I'll take a look and report back
k

Kyle Moon-Wright

03/08/2021, 11:49 PM
Very strange, but that’s good to know. I’ll continue to look for more information on this.
a

André Bonatto

03/08/2021, 11:52 PM
Even though I'm running locally, I'm behind a proxy. Maybe there's an additional configuration I'm missing.
z

Zanie

03/09/2021, 12:02 AM
Hi! Could you share the output of
prefect diagnostics
a

André Bonatto

03/09/2021, 12:04 AM
Sure : {  "config_overrides": {},  "env_vars": [],  "system_information": {    "platform": "Windows-10-10.0.19041-SP0",    "prefect_backend": "server",    "prefect_version": "0.14.11",    "python_version": "3.8.5"  } }
z

Zanie

03/09/2021, 12:08 AM
Hmm. I don't see anything weird they. You may need to set the NO_PROXY env variable for the requests library to hit the correct localhost but I'm not sure how Windows handles proxies.
Can you access http://localhost:4200/graphql in your browser?
a

André Bonatto

03/09/2021, 12:09 AM
Yes! It shows a page titled Playground.
z

Zanie

03/09/2021, 12:48 AM
I'm concerned this is requests proxy issue. Can you try
set no_proxy=localhost
then run
python -c "import requests; requests.get('<http://localhost:4200/graphql').raise_for_status()>"
and
python -c "import requests; requests.get('<http://localhost:8080/').raise_for_status()>"
a

André Bonatto

03/09/2021, 12:56 AM
Error 400 for localhost:4200/graphql and nothing for localhost:8080/
z

Zanie

03/09/2021, 12:59 AM
Well that's good to hear, requests is behaving correctly.
What about
python -c "from prefect.client import Client; client = Client(); print(client.graphql({'query': {'tenant': {'id'}}}))"
a

André Bonatto

03/09/2021, 1:07 AM
400, Bad request. Unexpected name "tenant"
z

Zanie

03/09/2021, 1:09 AM
Interesting. It seems like your hasura metadata is incorrect, something has gone wrong in the initialization of the services.
Can you confirm what options you've set on the Server when you started it?
a

André Bonatto

03/09/2021, 1:14 AM
Installed prefect on a fresh venv. Then switched backend with prefect backend server. Finally, prefect server start
👍 1
z

Zanie

03/09/2021, 1:17 AM
Can you share the output of
docker ps
?
a

André Bonatto

03/09/2021, 1:17 AM
Sure!
z

Zanie

03/09/2021, 1:17 AM
Thanks again for being patient 🙂 we're really confused by what's up here
a

André Bonatto

03/09/2021, 1:20 AM
It's me the one who should say thank you.
Here it goes. Output of docker ps
CONTAINER ID  IMAGE                          COMMAND                 CREATED        STATUS                  PORTS                   NAMES 03f06d75c68a  prefecthq/apollo:core-0.14.11  "/tini -g -- bash -c…"  4 minutes ago  Up 4 minutes (healthy)  0.0.0.0:4200->4200/tcp  temp_apollo_1 8ebb7abadbcb  prefecthq/server:core-0.14.11  "tini -g -- bash -c …"  4 minutes ago  Up 4 minutes (healthy)  0.0.0.0:4201->4201/tcp  temp_graphql_1 ff19c300efaa  hasura/graphql-engine:v1.3.0   "graphql-engine serve"  4 minutes ago  Up 4 minutes (healthy)  0.0.0.0:3000->3000/tcp  temp_hasura_1 ae9e1406e258  postgres:11                    "docker-entrypoint.s…"  4 minutes ago  Up 4 minutes (healthy)  0.0.0.0:5432->5432/tcp  temp_postgres_1
And here's the terminal output when I launch the server
z

Zanie

03/09/2021, 1:22 AM
Ah the containers are healthy, that's weird.
That log looks broken for sure. That'll be really helpful. I've got to sign off for a bit (might have to get back into it tomorrow) but someone else may be able to respond as well.
a

André Bonatto

03/09/2021, 1:24 AM
Ok! Thanks @Zanie
It seems the problem is related to the server port. When I ran prefect server start --server-port 8100 --detach, the dashboard appeared, but I still cannot register a new tenant
c

Chris White

03/09/2021, 1:50 AM
Hi @André Bonatto I’m going to convert this whole thread into a GitHub issue as I think that’s a more appropriate forum given how in-depth this has gotten; we can all follow-up there @Marvin open “Issue sending requests to my Server instance from the CLI”
z

Zanie

03/09/2021, 3:18 PM
When you go to http://localhost:4200/graphql in the browser there is a
Schema
button on the right side. If you open it, is there a schema defined? Can you run the query there?
The other user having a similar issue had another service running on 4200 (Angular), it may also be worth looking into what else could be using it especially if changing the port got things working. You will not be able to create the default tenant because
prefect server start
creates one for you by default, perhaps that's why you're encountering that error.
a

André Bonatto

03/09/2021, 4:14 PM
Hi. This query returns an empty list, but it seems to be working.
I suspect my firewall is blocking ports below 8000. If that's the case, is it possible to change the default ports in the config.toml?
z

Zanie

03/09/2021, 4:37 PM
Yeah if that query works then there's nothing wrong with Server just your networking. You can definitely change the ports in the config, they'll set the defaults for the CLI flags that would be passed to
prefect server start
a

André Bonatto

03/09/2021, 10:55 PM
Fixed! My proxy was blocking the requests so I disabled the proxy for the local host. @Zanie Thank you very much for your attention!
💯 1