Hasura Console error: [...] No connection could be made because the target machine actively refused it

Viewed 1669

I have the Docker toolbox version installed to be able to run Hasura locally. Docker is fully functional (I think) and up-to-date and can successfully pull images and spin up containers. I think the Hasura CLI is successfully installed as well, as some commands like hasura version or --help can be successfully executed; however, when I try to run the hasura console command in the terminal, this error is returned:

time="2020-09-15T09:28:16-05:00" level=fatal msg="version check: failed to get version from server: failed making version api call: Get http://localhost:8080/v1/version: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it."

I entirely disabled my antivirus and all firewalls I can find, as well as making a PATH environment variable for hasura like the documentation suggests, and ran the command again but that didn't fix the issue.

Does anyone know what might be causing this? I apologize if the question is vague, I'm very new to both Docker and Hasura. Please let me know if any further info is needed! Thank you!!

2 Answers

I believe the reason might be that the graphql-engine wasn't running. Try this:

  1. Run hasura init
  2. In the root directory create docker-compose.yaml file with the following content:
version: '3.6'

services:

  postgres:
    image: postgres:13.0
    restart: always
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: postgres

  graphql-engine:
    image: hasura/graphql-engine:latest
    ports:
      - "8080:8080"
    depends_on:
      - "postgres"
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
      HASURA_GRAPHQL_DEV_MODE: "true"
      HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
      HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
volumes:
  db_data:

Also see this: https://hasura.io/docs/1.0/graphql/core/getting-started/docker-simple.html#docker-simple

  1. Start docker services with docker-compose up
  2. In another terminal run hasura console --admin-secret myadminsecretkey. You should see the network address of the console in the terminal output.

I'm a complete noob with hasura, but encountered this problem myself.

This is the real solution: Run the command in powershell as admin. make sure the config.yaml points to the localhost:PORT that your graphql-engine instance is running on.

I.E Follow docker setup process, run graphql-engine (on docker) Next: hasura init -> edit config.yaml point it to where engine is running -> hasura console

Related