Skip to main content
Most database connection failures on Square Cloud come down to one of three things: a connection without SSL/TLS or without the certificate, an IP allowlist that doesn’t account for a dynamic IP, or wrong credentials. Match the exact error below.

Connection refused without SSL/TLS or the certificate

What it means: the database refuses the connection before checking the password: Why it happens: Square Cloud’s hosted databases require SSL/TLS on every connection. PostgreSQL and MongoDB also require the client certificate; MySQL and Redis need only TLS. How to fix:
  1. Open the database in the Square Cloud dashboard and download the certificate: the .pem (private key and certificate in one file), or the same pair split into .crt and .key.
  2. Load it in your client:
    • PostgreSQL: sslmode=require with sslcert and sslkey both pointing to the .pem (for sslmode=verify-full, also sslrootcert).
    • MySQL: ssl-mode=REQUIRED, or VERIFY_CA with the .pem as the CA. No client certificate is needed.
    • MongoDB: tls=true with tlsCertificateKeyFile and tlsCAFile both pointing to the .pem.
    • Redis: a rediss:// URL (two s’s), with the .pem as the CA (details below).
    • GUI clients (MySQL Workbench, DBeaver, HeidiSQL, pgAdmin, MongoDB Compass): set the downloaded files in the client’s SSL/TLS tab, then connect with the host, port, user and password shown in the dashboard.
    • Prisma ORM (PostgreSQL or MySQL): convert the certificate and key into a .p12:
      Then set (postgresql:// the same way):
      Ship client.p12 inside the app’s zip and set DATABASE_URL in the application’s environment variables, then restart the application.
  3. Verify the username and password match what’s shown in the dashboard.
Never commit certificate.pem or client.p12 to a public repository, keep it out of version control, but do include it in the deploy .zip when your app reads it from disk.

MySQL “ER_NOT_SUPPORTED_AUTH_MODE”

What it means: the login fails with ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server. Why it happens: the MySQL databases accept only the caching_sha2_password authentication. Older drivers, such as the npm mysql package, don’t support it. How to fix: switch to a driver that does, such as mysql2 on Node.js (it keeps the mysql API for most code), or update your connector to a current version.

MongoNetworkError and MongoDB Atlas IP whitelist failures

What it means: an externally-hosted MongoDB Atlas cluster (not a Square Cloud managed database) refuses the connection with MongoNetworkError: connection ... closed, even though the credentials are correct. Why it happens: Square Cloud application containers use a dynamic IPv4 address that changes on every restart. A MongoDB Atlas IP allowlist configured for a single static IP will work until the next restart, then silently break. How to fix, choose one:
  1. Recommended if you need external Atlas: in Atlas → Network Access, add 0.0.0.0/0 to allow connections from any IP, and compensate for the wider allowlist with strong credentials (long random password, dedicated database user, connection string kept only in environment variables). See also MongoDB Atlas with a dynamic IP.
  2. Recommended overall: move the database to a Square Cloud managed database instead of an external Atlas cluster. Hosting the database next to the app removes the IP-allowlist problem entirely and gives near-zero latency.

Connection timeout and ECONNREFUSED

What it means: the app hangs until it times out, or fails immediately with ECONNREFUSED, when trying to reach a database. Why it happens, as a rule of thumb:
  • A timeout (the connection hangs, no immediate rejection) usually means a firewall or IP allowlist on the destination database is blocking the connection. Many external providers block datacenter/foreign IPs by default.
  • An immediate ECONNREFUSED or “authentication failed” usually means the host/port is reachable but the credentials, database name, or port number are wrong.
How to fix:
  1. If connecting to an external provider (not a Square Cloud managed database), allow Square Cloud’s ASNs on the destination firewall: 398395 and 26548. Where only IP-based allowlisting is supported (like MongoDB Atlas), use 0.0.0.0/0 with strong credentials instead, since the source IP is dynamic.
  2. Double-check host, port, username, and password against what the provider or the Square Cloud dashboard shows.
  3. URL-encode any special characters in the connection string (@, :, /, etc. inside a password will break parsing if left raw).
  4. Check whether the provider’s driver requires an explicit ssl=true (or similar) parameter in the connection string.

SSL/TLS connection errors

What it means: the client fails to establish a TLS handshake with the database, or fails right after with an authentication-looking error that’s actually a certificate problem. Why it happens: Square Cloud managed databases require SSL on every connection. Each database engine expects the certificate in a slightly different shape:
  • Redis: the protocol must be rediss:// (two s’s), never redis://. Shape: rediss://default:PASSWORD@HOST:PORT. node-redis also accepts socket: { tls: true, ca: fs.readFileSync("certificate.pem") }; Python’s redis library takes ssl_ca_certs/ssl_certfile/ssl_keyfile (the combined certificate.pem downloaded from the dashboard works for all of them).
  • Drizzle ORM (Postgres): a standard pg Pool with ssl: { ca, cert, key }, all loaded via fs.readFileSync from the combined certificate.pem, and the same ssl object in drizzle.config.ts.
  • JDBC (Java): the client key must be converted to PK8/DER format and referenced in the JDBC URL’s SSL properties.
  • libpq (psql, psycopg2): private key file ... has group or world access means the .pem is readable by other users: restrict it with chmod 600 certificate.pem (in Python, os.chmod("certificate.pem", 0o600) before connecting).
  • Go: full host name verification fails with x509: certificate relies on legacy Common Name field, because the certificate names the host only in its Common Name. Verify the certificate without the host name instead: sslmode=verify-ca on PostgreSQL, VERIFY_CA on MySQL.
How to fix: re-download the certificate from the database’s page in the dashboard (an old or partial certificate file is a common cause: after a certificate reset, the previous file stops working) and confirm the connection string uses the TLS-enabled protocol/scheme for your engine.
If the error message doesn’t match anything above, our support team can help diagnose the exact connection failure.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.