When connecting your website or application to your Managed Database Hosting, you may sometimes encounter a “Connection Refused” error.
This happens when your application tries to reach the database, but the server rejects the connection. Below are the common reasons and their solutions.
1. Access Restrictions
For security, databases only allow connections from approved IP addresses. If your hosting server’s IP is not authorized, the connection will be refused.
How to Fix the Issue
Option A : Whitelist Your Hosting Server IP
- Find your hosting server’s IP address.
- Open a support ticket with Provider.lk and request to whitelist the IP.
- Once approved, your hosting will be able to connect to the database.
Option B: Enable Wildcard IP Access
- If your hosting IP changes often or you don’t have a fixed IP, request wildcard IP support.
- Wildcard allows connections from any IP.
- For security reasons, your database password will be reset to a stronger one.
- Use this new password to connect.
- If wildcard access is enabled, update your app with the new database password.
2. Configuration Problems
Incorrect database settings in your application can block the connection. Examples include using the wrong host, port, or database name, having the database listen only on localhost instead of allowing external connections.
How to Fix the Issue
- Check and correct the host, port, database name, username, and password.
- Ensure the database allows external connections.
3. Authentication & Permissions
Invalid database credentials or insufficient user privileges can block the connection.
How to Fix the Issue
- Double-check the database username and password.
- Ensure the user has remote access privileges.
- If the password was reset due to wildcard access, update your application with the new credentials.
Following these steps will help resolve most “Connection Refused” errors and restore your database connection.