ORA-12545: Connect failed because target host or object does not exist ORA-06512

Shaban Mousa picture Shaban Mousa · Dec 11, 2011 · Viewed 16.6k times · Source

I have the following error message when I try to establish a HTTP request connection:

ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1029 ORA-12545: Connect failed because target host or object does not exist ORA-06512: at line 10 .

Line 10 is the following:

req := UTL_HTTP.BEGIN_REQUEST('oracle.com'); 

Here is my pl/sql block:

DECLARE 
    req UTL_HTTP.REQ; 
    resp UTL_HTTP.RESP; 
    name_1 VARCHAR2(256); 
    value_1 VARCHAR2(1024); 
    v_msg VARCHAR2 (500);

BEGIN 
    req := UTL_HTTP.BEGIN_REQUEST('http://www.oracle.com'); 
    UTL_HTTP.SET_HEADER(req, 'User-Agent', 'Mozilla/5.0'); 
    UTL_HTTP.SET_FOLLOW_REDIRECT(req, 0); 
    resp := UTL_HTTP.GET_RESPONSE(req); 
    LOOP
        Utl_Http.read_text (resp, v_msg);
        DBMS_OUTPUT.put_line (v_msg);
    END LOOP;

    UTL_HTTP.END_RESPONSE(resp);
EXCEPTION
    WHEN Utl_Http.end_of_body
        THEN
        NULL; 
END;

Answer

Yahia picture Yahia · Dec 11, 2011

the code seems fine to me...

the reason of this error is outside the code you show:

The system this code is run on (the DB server) must be able to resolve the domain name - which has nothing to do with Oracle...

To solve this you need to setup DNS / hosts correctly on the machine / in the OS!