Hi folks. When I try to create a tenant with the c...
# prefect-server
a
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
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
Hi Kyle. Yes, I'm trying to run on my laptop.
k
What version of Prefect are you running? You can find out by running
prefect version
a
I believe it's the latest : 0.14.11
k
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
Just tried that I received the same 401 Client Error
k
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
I didn't change nothing, I was just following the tutorial. Thanks for the thread. I'll take a look and report back
k
Very strange, but that’s good to know. I’ll continue to look for more information on this.
a
Even though I'm running locally, I'm behind a proxy. Maybe there's an additional configuration I'm missing.
z
Hi! Could you share the output of
prefect diagnostics
a
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
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
Yes! It shows a page titled Playground.
z
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
Error 400 for localhost:4200/graphql and nothing for localhost:8080/
z
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
400, Bad request. Unexpected name "tenant"
z
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
Installed prefect on a fresh venv. Then switched backend with prefect backend server. Finally, prefect server start
👍 1
z
Can you share the output of
docker ps
?
a
Sure!
z
Thanks again for being patient 🙂 we're really confused by what's up here
a
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
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
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
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
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
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
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
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