I'm encountering an issue while attempting to connect my Laravel 8 project (using PHP 7.4) to a staging Oracle database. Despite configuring the necessary files (listener.ora, tnsnames.ora), and updating my .env file with the staging database credentials, I'm consistently getting the following error when running php artisan serve:
ORA-12170: TNS:Connect timeout occurred
Here's an overview of my setup:
Instant Client Directory: I've placed all necessary files in /opt/oracle/instantclient_21_13, with tnsnames.ora being the main file.
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.70.236.30)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = UWBSDBPROD)
)
)
Listener Configuration:
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=10.70.236.30)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.70.236.30)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = UWBSDBPROD)
)
)
Laravel .env Configuration:
DB_CONNECTION=oracle
DB_HOST=10.70.236.30
DB_PORT=1521
DB_DATABASE=database
DB_USERNAME=whatsappdb
DB_PASSWORD=whatsapp
DB_CHARSET=utf8
DB_COLLATION=utf8
DB_DEBUG=true
Despite these configurations, I'm still encountering the ORA-12170 error. Could someone please assist me in resolving this issue? Any help would be greatly appreciated. Thank you. It is help for me I'm trying this for several days but can't find any result.
Here's the corrected version of your text:
First, you can perform a connection test from your client.
If this is successful, try to connect with sqlplus:
or
If you can connect with sqlplus, then there is likely a problem with the Laravel configuration (assuming you're using Laravel).
What version of Oracle are you using?
You don't need to add the instance to the listener configuration in
listener.ora. The instance will register with the listener automatically.You can check this with the following command: