You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法连接Hostinger Oracle数据库:Oracle.ManagedDataAccess.Client连接请求超时问题求助

Troubleshooting "Connection request timed out" with Hostinger Oracle Database and Oracle.ManagedDataAccess.Client

Hey there, let's work through this connection timeout issue you're hitting with your Hostinger Oracle database. I've run into similar headaches before, so here are actionable steps to diagnose and fix it:

1. Double-Check Your Connection String Values

First off, make sure every part of your DataSource is exactly what Hostinger provided you:

  • Hostname: Hostinger might give you a specific domain (not just an IP) for your Oracle instance—confirm you're using that instead of guessing.
  • Port: Oracle's default is 1521, but Hostinger could be using a custom port. Verify this in your Hostinger control panel.
  • Database Identifier: The database part in your hostname:port/database format should be the service name (not the SID) of your Oracle instance. If Hostinger provided a SID instead, you'll need to switch to the full TNS-style connection string:
    stringBuilder.DataSource = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=your-hostinger-hostname)(PORT=your-port))(CONNECT_DATA=(SID=your-database-sid)))";
    

2. Confirm Network & Firewall Access

Even if you enabled remote access in Hostinger, there are a few gotchas here:

  • Whitelisted IP: Make sure your public IP address is added to Hostinger's allowed remote IP list. It's easy to accidentally use your internal LAN IP instead of your external one—you can check your public IP by searching "what's my IP" in your browser.
  • Local Firewall/Antivirus: Your machine's firewall or antivirus might be blocking outbound connections to the Oracle port. Test connectivity manually using telnet or nc (replace with your host and port):
    telnet your-hostinger-hostname 1521
    # Or using nc
    nc -zv your-hostinger-hostname 1521
    
    If this command fails, your local network is blocking the connection—adjust your firewall settings accordingly.

3. Validate the Oracle.ManagedDataAccess.Client Version

Version mismatches between your client and Hostinger's Oracle server can cause weird connection issues. Make sure you're using a stable, compatible version:

  • Head to NuGet Package Manager in your project and update Oracle.ManagedDataAccess.Client to the latest stable release.
  • If Hostinger's server is running a specific Oracle version (e.g., 19c), try matching your client version to that for better compatibility.

4. Test with a Third-Party Tool First

Rule out code issues by connecting to your database using a tool like Oracle SQL Developer or DBeaver:

  • Use the exact same credentials, host, port, and service/SID as in your code.
  • If the tool can't connect either, the problem is definitely on the Hostinger/network side. If it can connect, then we know to focus on your code.

5. Adjust Connection Timeout Settings

Sometimes the default timeout is too short for slower network connections. Add an explicit timeout to your connection string builder:

stringBuilder.ConnectionTimeout = 30; // 30 seconds, adjust as needed

Example Revised Code

Here's your code with some error handling and optional adjustments:

using Oracle.ManagedDataAccess.Client;
using System;

class Program
{
    static void Main()
    {
        using (OracleConnection connection = new OracleConnection())
        {
            OracleConnectionStringBuilder stringBuilder = new OracleConnectionStringBuilder();
            stringBuilder.Password = "NotFakePassword";
            stringBuilder.UserID = "NotFakeUserName";
            // Use either service name format or TNS format based on Hostinger's info
            stringBuilder.DataSource = "your-hostinger-hostname:1521/your-service-name";
            // stringBuilder.DataSource = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=your-hostinger-hostname)(PORT=1521))(CONNECT_DATA=(SID=your-database-sid)))";
            stringBuilder.ConnectionTimeout = 30;

            connection.ConnectionString = stringBuilder.ConnectionString;

            try
            {
                connection.Open();
                Console.WriteLine("Successfully connected to the database!");
            }
            catch (OracleException ex)
            {
                Console.WriteLine($"Connection failed: {ex.Message}\nError Number: {ex.Number}");
            }
            // Using 'using' statement will automatically close the connection, so no need for explicit Close()
        }
    }
}

内容的提问来源于stack exchange,提问作者dingdeveloper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 19:18:13