cancel
Showing results for 
Search instead for 
Did you mean: 

UTL_TCP: Connection refused

SOLVED
Go to solution
Ryan Kogelheide
Frequent Advisor

UTL_TCP: Connection refused

SQL> set serveroutput on size 100000
SQL> Declare
2 con UTL_TCP.connection;
3 ret PLS_INTEGER;
4 Begin
5 con := UTL_TCP.open_connection ('127.0.0.1',3001);
6 dbms_output.put_line('Connection Opened');
7 UTL_TCP.close_connection(con);
8 dbms_output.put_line('Fini.');
9 exception
10 when others then
11 UTL_TCP.close_all_connections;
12 raise;
13 End;
14 /
Declare
*
ERROR at line 1:
ORA-20002: Connection refused
ORA-06512: at line 12

I get the same error with a C++ program. What is required to open a port on HP-UX? For example, does the port have to be declared somewhere like /etc/services (I'm skeptical of this since Forms Server listens on 9001 and it's not declared)?
5 REPLIES
Bill McNAMARA_1
Honored Contributor
Solution

Re: UTL_TCP: Connection refused

try running
netstat -an
to view all network ports and services established and listening.

Later,
Bill
It works for me (tm)
Ryan Kogelheide
Frequent Advisor

Re: UTL_TCP: Connection refused

Hey Bill,

netstat -an shows my little listener that I wrote in C++, but on 127.0.0.1.

Ryan
Ryan Kogelheide
Frequent Advisor

Re: UTL_TCP: Connection refused

Hmmm... I realize that that sounds strange. I hid the real IP address I'm using in the original post with 127.0.0.1.

The code to open the connection uses a gethostbyname on the "real" 127.0.0.1. I think this is the problem...
Ryan Kogelheide
Frequent Advisor

Re: UTL_TCP: Connection refused

Well. If I change the IP of the host=gethostbyname() to the primary interface, the C++ test connection now works (though it's interesting that other daemons have *. in the netstat output).

The C++ test conn program is on the same host as the test listener.

The Oracle connection from a remote Win2K PC doesn't work and returns the same "Connection refused" as above.

I assume I'm not meeting proxy problems because I can ftp from the Win2K PC.
Ryan Kogelheide
Frequent Advisor

Re: UTL_TCP: Connection refused

The problem was that there were several interfaces on this machine and I was listening on the wrong one.

The problem with UTL_TCP was resolved by reinstalling the Oracle JVM.