Can not connect to oracle database with ip address

oraclesqlplustnsnames

I am new to oracle database, I have installed Oracle 11.g on redhat 5.6, I have a database that I can connect to it using the following command:

export ORACLE_SID=test
sqlplus user/passwd

but not connect to database neither remotely nor from localhost:
sqlplus user/passwd@myhost:1521/test
error:
ORA-12541: TNS: no listener

this is my listener.ora file:

# listener.ora Network Configuration File: 

/Oracle/oracle_base/product/11.2.0.4/database/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
      (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1522))
    )
  )

ADR_BASE_LISTENER = /Oracle/oracle_base

this inside tnsnames.ora file:

test =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = test)
    )
  )

and this is output of lsnrctl status is:

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-JAN-2017 

15:57:02

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                16-JAN-2017 15:45:32
Uptime                    0 days 0 hr. 11 min. 30 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /Oracle/oracle_base/product/11.2.0.4/database/network/admin/listener.ora
Listener Log File         /Oracle/oracle_base/diag/tnslsnr/myhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhost)(PORT=1522)))
The listener supports no services
The command completed successfully

and this is output of tnsping test:

oracle> tnsping test

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 16-JAN-2017 16:00:45

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
/Oracle/oracle_base/product/11.2.0.4/database/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = test)))
TNS-12541: TNS:no listener

Best Answer

Listener listens on port 1522, but you are trying to connect port 1521. Update your tnsnames.ora with the correct port number (1522).