dockerubuntugraphqlhasurahasura-docker

Hasura action handler does not exist (Name or service not known)


I have an instance of Hasura running in the Docker container and action handler API written in NodeJS/Express running directly on the machine.

When I test everything locally it works like a charm ( macOS M1 ), but when I replicate the same setup on the server ( Ubuntu 20.04 ) it returns an action handler does not exist error.

All other queries and mutations work well, just actions return this error

You can see that both Hasura and NodeJS apps are running

hasura docker container

localhost api call

In local development my action handler base url is

http://host.docker.internal:5000/api

and it is working fine. I have also tried

http://localhost:5000/api

http://127.0.0.1:5000/api

This is the exact error Hasura action call returns

{
"errors": [
    {
        "extensions": {
            "internal": {
                "error": {
                    "type": "http_exception",
                    "message": "ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = 0.0.0.0:0, addrCanonName = Nothing}, host name: Just \"host.docker.internal\", service name: Just \"5000\"): does not exist (Name or service not known)"
                },
                "response": null,
                "request": {
                    "body": {
                        "session_variables": {
                            "x-hasura-role": "public"
                        },
                        "input": {
                            "email": "",
                            "password": ""
                        },
                        "action": {
                            "name": "login"
                        }
                    },
                    "url": "http://host.docker.internal:5000/api/auth/login",
                    "headers": []
                }
            },
            "path": "$",
            "code": "unexpected"
        },
        "message": "http exception when calling webhook"
    }
]

}


Solution

  • If someone encounters the same issue this is how I solved it

    Add this to docker-compose.yml file

        extra_hosts:
        - "host.docker.internal:host-gateway"
    

    Allow ports 8080 and 5000 in firewall

     sudo ufw allow 8080 
     sudo ufw allow 5000