appwrite: 🐛 Bug Report: Error Invalid endpoint or your Appwrite server is not running as expected

👟 Reproduction steps

When i try to login using Appwrite CLI and Server Name (FQDN), i get this error message:

✗ Error Invalid endpoint or your Appwrite server is not running as expected.

I have a Nginx as reverse proxy and already did a lot of configurations. A simple curl is ok:

curl https://appwrite.domain.com/v1/health/version
{"version":"1.2.1"}

Login with IP address, fine!

$ appwrite login
? Enter your email [felipe@domain.com](mailto:felipe@domain.com)
? Enter your password *******
? Enter the endpoint of your Appwrite server http://10.0.0.1/v1
✓ Success

Login with FQDN, fail…

$ appwrite login
? Enter your email [felipe@domain.com](mailto:felipe@domain.com)
? Enter your password *******
? Enter the endpoint of your Appwrite server https://appwrite.domain.com/v1
✗ Error Invalid endpoint or your Appwrite server is not running as expected.

Testing CLI with --verbose

> appwrite client --endpoint https://appwrite.domain.com/v1 --verbose
Error: Invalid endpoint or your Appwrite server is not running as expected.
    at C:\snapshot\sdk-for-cli\lib\commands\generic.js:90:23
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

OBS: Could not find C:\snapshot\sdk-for-cli\ im my computer. Is it normal?

This is the Nginx server config /etc/nginx/sites-enabled/appwrite.conf :

server{
       listen 80;
       server_name appwrite.domain.com;
       return 301 https://appwrite.domain.com$request_uri;
}
server{
       listen 443 ssl;
       server_name appwrite.domain.com;
       location / {
              proxy_set_header Upgrade    $http_upgrade;
              proxy_set_header Connection $http_connection;
              proxy_http_version 1.1;
              add_header       X-Served-By        $host;
              proxy_set_header X-Forwarded-Scheme $scheme;
              proxy_set_header X-Forwarded-Proto  $scheme;
              proxy_set_header X-Forwarded-Host   $host;
              proxy_set_header X-Forwarded-For    $remote_addr;
              proxy_set_header Host       $host;
              proxy_set_header X-Real-IP  $remote_addr;
              proxy_pass http://10.0.0.1;
       }
}

SSL settings are in nginx.conf

👍 Expected behavior

$ appwrite login ? Enter your email felipe@domain.com ? Enter your password ******* ? Enter the endpoint of your Appwrite server https://appwrite.domain.com/v1 ✓ Success

👎 Actual Behavior

$ appwrite login ? Enter your email felipe@domain.com ? Enter your password ******* ? Enter the endpoint of your Appwrite server https://appwrite.domain.com/v1 ✗ Error Invalid endpoint or your Appwrite server is not running as expected.

🎲 Appwrite version

Version 1.2.x

💻 Operating system

Linux

🧱 Your Environment

Cloud Provider: Azure Appwrite Version: 1.2.1 Nginx - Reverse Proxy

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn’t find similar issue

🏢 Have you read the Code of Conduct?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

Thanks for reaching out on Discord! 🙏🏼

After modifying the error handler to log the exception, I saw the error was:

$ appwrite client --endpoint https://appwrite.domain.com/v1    
AppwriteException [Error]: unable to verify the first certificate
    at Client.call (/Users/steven/.nvm/versions/node/v16.16.0/lib/node_modules/appwrite-cli/lib/client.js:223:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/steven/.nvm/versions/node/v16.16.0/lib/node_modules/appwrite-cli/lib/commands/generic.js:74:32 {
  code: undefined,
  response: undefined
}
✗ Error Invalid endpoint or your Appwrite server is not running as expected.

It seems the certificate on your server didn’t have the full certificate chain so node wasn’t able to fully verify the certificate. The workaround is either to:

  1. Update the server to use an SSL certificate with the full chain
  2. Force the Appwrite CLI to ignore the SSL error by manually updating ~/.appwrite/prefs.json to set the endpoint to your endpoint and selfSigned to true.