hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.08k stars 2.77k forks source link

Error Using CLI Console, can't GET http://0.0.0.0:9693/apis/migrate/settings #6048

Open duskmoon314 opened 3 years ago

duskmoon314 commented 3 years ago

I'm following the doc Setting up Hasura migrations. I want to use hasura console, and try step 5.

I am using a Ubuntu 16.04 server, having hasura engine and postgres in docker:

CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                     NAMES
d2a2eb158d5e        hasura/graphql-engine:latest   "graphql-engine serve"   17 minutes ago      Up 17 minutes       0.0.0.0:23333->8080/tcp   hasura
af35fe785fac        postgres:12                    "docker-entrypoint.s…"   25 hours ago        Up 4 hours          0.0.0.0:5432->5432/tcp    postgres

I use this command on a Ubuntu 16.04 server:

hasura console --address 0.0.0.0 --no-browser
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      28693/sshd
tcp6       0      0 :::5432                 :::*                    LISTEN      16419/docker-proxy
tcp6       0      0 :::9693                 :::*                    LISTEN      19396/hasura
tcp6       0      0 :::9695                 :::*                    LISTEN      19396/hasura
tcp6       0      0 :::23333                :::*                    LISTEN      19289/docker-proxy

Then I tried to open the console, and got this:

image

It seems that the port for migrating isn't working correctly. How can I solve this problem?


my config.yaml:

version: 2
endpoint: http://<server_ip_address>:23333
admin_secret: <admin_secret>
jwt_secret: <jwt_secret>
metadata_directory: metadata
actions:
  kind: synchronous
  handler_webhook_baseurl: http://localhost:3000

hasura docker env:

HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:<postgres_password>@postgres:5432/postgres
HASURA_GRAPHQL_ADMIN_SECRET=<admin_secret>
HASURA_GRAPHQL_JWT_SECRET=<jwt_secret>
ACTION_SECRET=<action_secret>
HASURA_GRAPHQL_CORS_DOMAIN="*"
# USE hasura console instead
# HASURA_GRAPHQL_ENABLE_CONSOLE="true"
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR=/srv/console-assets
UNAUTHORIZED_ROLE=anonymous
duskmoon314 commented 3 years ago

On server, I get this:

$ curl -G 0.0.0.0:9693/apis/migrate/settings
{"migration_mode":"true"}

Is this a server problem?

duskmoon314 commented 3 years ago

I find a solution: use hasura cli on my pc

x0y-gt commented 3 years ago

Can this be reopened? Its happening exactly the same to me.

But I think this is an error because if I want to configure the console to listen on any IP it should be smart enough to make a request to the IP of the server instead of send the request to 0.0.0.0

duskmoon314 commented 3 years ago

@x0y-gt OK

jkopb commented 3 years ago

It would be great if this bug could be fixed. The current implementation makes it impossible to run the console in environments where you cannot control the public URL.

I'm for instance having issues setting it up on Gitpod.io. Gitpod automatically creates a public URL for each server process running on localhost, and this address cannot be customized. This makes it impossible to run hasura console, as the migration server ends up running on a different URL than the console server, but the console app makes requests to localhost.

Currently, I have to work around the issue by using JS user scripts through browser extensions, which manually redirect the requests to the correct migration server URL.

hutchic commented 3 years ago

I think my hack is similar to @jbuverud

In chrome set a breakpoint at line 22 of the api-explorer source

image

When the breakpoint triggers adjust the configuration as necessary

window.__env.apiHost = "http://x.x.x.x"

Then continue from the breakpoint

Could this please allow a environment variable / .env file override?

sam-artuso commented 2 years ago

Having the same exact problem... has anyone found a solution?

m-Bilal commented 1 year ago

We recently added a flag to the CLI that should fix this. Could you folks try that out and let us know if it works for your use case?

andoks commented 1 year ago

@m-Bilal I still have problems trying to run hasura console in a docker container, in particular on windows with docker desktop, and this here seems to be one of the possible issues (https://github.com/hasura/graphql-engine/issues/2824#issuecomment-1482954035) I had to set --console-hge-endpoint=http://localhost:8080 to make anything work at all. On linux it mostly works, with some errors in the firefox developer console still though.

dgbau commented 1 year ago

I might have a solution! I have been running into this same/similar issue, trying to launch the console from a VS Code SSH session. I found that VSC was porting 9695 automatically when the command was run, but was not porting 9693. I manually added that port to the forwarding, and now the call to http://localhost:9693/apis/migrate/settings succeeds. I am not using any flags in the console command besides --project, --secret and --endpoint.

It seems like this is new, either 9693 was getting automatically added to forwarded ports before, or the calls to the above URL were on 9695.

m-Bilal commented 1 year ago

@andoks , sorry, I lost track of this issue. I'll be looking into it over the next 2 weeks