API timeout issues

The API returns a 504 Gateway Timeout error when accessed through the nginx reverse proxy.

About this task

Symptom

Direct access to the FastAPI backend works, but external access through the nginx proxy returns a 504 Gateway Timeout error.

Cause

The nginx configuration uses the hostname metaltank to proxy requests to the FastAPI backend, but this hostname is not resolvable via DNS or /etc/hosts on the Provisioner server itself, causing nginx to fail connecting to the backend.

Procedure

  1. Verify that the FastAPI backend is running and listening on port 8000.
    curl http://localhost:8000/login
    ss -tlnp | grep 8000
  2. Verify that nginx is running.
    systemctl status metaltank-webserver.service
  3. Test hostname resolution for metaltank on the Provisioner server.
    ping -c 1 metaltank

    If the hostname cannot be resolved, add it to /etc/hosts:

    echo "127.0.0.1   metaltank" | sudo tee -a /etc/hosts
  4. Restart the nginx service to apply the fix.
    systemctl restart metaltank-webserver.service
  5. Verify that external API access is restored.
    curl -k https://provisioner-ip:443/api/

Results

The nginx proxy can resolve the metaltank hostname and API requests are no longer timing out.