Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Databases and Redis

UTL_HTTP calls fail with ORA-29273 because the database blocks the host

Your error

ORA-29273: HTTP request failed1 more line it can show

Fix it fast

Most common cause, 1 of 3

No access control entry names this user for the host

As a user with the right to administer network ACLs, append an entry for the host that grants http to the schema making the call.

Fix
BEGIN
  DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
    host => 'api.example.com',
    ace  => xs$ace_type(privilege_list => xs$name_list('http'),
                        principal_name => 'APP_USER',
                        principal_type => xs_acl.ptype_db));
END;
/
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

ORA-29273 HTTP request failed with ORA-24247 network access denied by access control list (ACL) means no ACE lets the calling database user reach that host and port. Run DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE as an administrator with privilege http, principal_type xs_acl.ptype_db and a port range that covers the URL. Applies to Oracle AI Database 26ai and 19c.

  • Applies to Oracle AI Database 26ai, Oracle Database 19c, UTL_HTTP and DBMS_NETWORK_ACL_ADMIN
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Connect as the user that runs the HTTP call and ask the database which grants apply to the target host. No row at all points to cause 1 or 3, and the DBA query in cause 3 tells them apart. A GRANTED row whose ports miss the URL's port is cause 2.

Run this first
SELECT host, lower_port, upper_port, privilege, status
FROM (SELECT aces.*,
             DBMS_NETWORK_ACL_UTILITY.CONTAINS_HOST('api.example.com', host) precedence
      FROM user_host_aces aces)
WHERE precedence IS NOT NULL
ORDER BY precedence DESC, lower_port NULLS LAST, upper_port NULLS LAST;

Then find the line you see in this list and open its fix:

  1. 1No access control entry names this user for the hostUSER_HOST_ACES returns no row for the host when queried as the calling user
  2. 2The entry covers a different port than the URL usesUSER_HOST_ACES shows the host as GRANTED, but LOWER_PORT and UPPER_PORT are both 80 while the code calls an https:// URL on 443 (or a custom port)
  3. 3The ACE was created without principal_type, so it targets an application userDBA_HOST_ACES has a row with the right host and user name, but PRINCIPAL_TYPE is not DATABASE USER, and USER_HOST_ACES shows nothing for that user

What does the error look like?

  • ORA-29273: HTTP request failed
  • ORA-24247: network access denied by access control list (ACL)

Cause 1 of 3

No access control entry names this user for the host

You seeUSER_HOST_ACES returns no row for the host when queried as the calling user

Check

ORA-24247 is raised when no ACL is assigned to the target host, or when the ACL there does not grant the needed privilege to this user. Outbound calls through UTL_HTTP, UTL_TCP, UTL_SMTP and UTL_MAIL are all checked against these lists, so a schema with no entry for a host cannot reach it.

Check
-- as a DBA: every entry that could match the host
SELECT host, lower_port, upper_port, principal, principal_type, privilege
FROM dba_host_aces
WHERE DBMS_NETWORK_ACL_UTILITY.CONTAINS_HOST('api.example.com', host) IS NOT NULL;

Fix

As a user with the right to administer network ACLs, append an entry for the host that grants http to the schema making the call. Granting only http, rather than connect, keeps the schema limited to UTL_HTTP and HttpUriType.

Fix
BEGIN
  DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
    host => 'api.example.com',
    ace  => xs$ace_type(privilege_list => xs$name_list('http'),
                        principal_name => 'APP_USER',
                        principal_type => xs_acl.ptype_db));
END;
/

Verify

The first-step query, run as APP_USER, now shows HTTP with status GRANTED, and the UTL_HTTP call returns a response instead of ORA-29273.

Verify
SELECT UTL_HTTP.REQUEST('http://api.example.com/') FROM dual;

Confirmed by docs.oracle.com

Did this fix it?

Cause 2 of 3

The entry covers a different port than the URL uses

You seeUSER_HOST_ACES shows the host as GRANTED, but LOWER_PORT and UPPER_PORT are both 80 while the code calls an https:// URL on 443 (or a custom port)

Check

A port range on an ACE limits it to those TCP ports. If lower_port is given and upper_port is left out, Oracle assumes upper_port equals lower_port, so an entry made for port 80 does nothing for a TLS call on 443. Access to a host on port 80 and other ports needs separate entries.

Check
SELECT host, lower_port, upper_port, privilege, status
FROM user_host_aces
WHERE host = 'api.example.com';

Fix

Add a second entry for the port the URL really uses, or create one with no port bounds when every port on that host is acceptable.

Fix
BEGIN
  DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
    host       => 'api.example.com',
    lower_port => 443,
    upper_port => 443,
    ace        => xs$ace_type(privilege_list => xs$name_list('http'),
                              principal_name => 'APP_USER',
                              principal_type => xs_acl.ptype_db));
END;
/

Verify

USER_HOST_ACES lists a GRANTED row whose port range includes 443, and the https call gets past the ACL check.

Verify
SELECT host, lower_port, upper_port, status FROM user_host_aces WHERE host = 'api.example.com';

Confirmed by docs.oracle.com

Did this fix it?

Cause 3 of 3

The ACE was created without principal_type, so it targets an application user

You seeDBA_HOST_ACES has a row with the right host and user name, but PRINCIPAL_TYPE is not DATABASE USER, and USER_HOST_ACES shows nothing for that user

Check

In xs$ace_type, principal_type defaults to PTYPE_XS, which means a Real Application Security application user. An entry built without xs_acl.ptype_db therefore does not apply to the database schema of the same name, even though the host and user name look right.

Check
SELECT host, principal, principal_type, privilege
FROM dba_host_aces
WHERE principal = 'APP_USER';

Fix

Append the entry again with principal_type => xs_acl.ptype_db. The name is not case sensitive unless you wrap it in double quotes, so match how the user was created.

Fix
BEGIN
  DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
    host => 'api.example.com',
    ace  => xs$ace_type(privilege_list => xs$name_list('http'),
                        principal_name => 'APP_USER',
                        principal_type => xs_acl.ptype_db));
END;
/

Verify

DBA_HOST_ACES shows a row for APP_USER with PRINCIPAL_TYPE DATABASE USER and privilege HTTP.

Verify
SELECT principal, principal_type, privilege FROM dba_host_aces WHERE principal = 'APP_USER';

Confirmed by docs.oracle.com

Did this fix it?

How do I stop it coming back?

  • Keep each schema's APPEND_HOST_ACE calls in the same migration that creates the code calling UTL_HTTP, so new environments get both together.
  • Always pass principal_type => xs_acl.ptype_db and an explicit port range in network ACE scripts, and review them in code review.
  • Add a deployment check that runs the USER_HOST_ACES query for each outbound host and fails if no GRANTED row covers the port.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.