Docker error : ORA-12541: Cannot connect. No listener at host localhost port 1521

I am trying to run my demo microservice in docker desktop but getting below error :
I have hosted oracle db in docker desktop.

2025-05-14T00:38:50.026Z ERROR 1 --- [demo] [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : ORA-12541: Cannot connect. No listener at host localhost port 1521. (CONNECTION_ID=7vNSSAivT6SrmiTWJdGREQ==)
https://docs.oracle.com/error-help/db/ora-12541/
2025-05-14T00:38:50.028Z  WARN 1 --- [demo] [           main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : HHH000342: Could not obtain connection to query metadata

org.hibernate.exception.GenericJDBCException: unable to obtain isolated JDBC connection [ORA-12541: Cannot connect. No listener at host localhost port 1521. (CONNECTION_ID=7vNSSAivT6SrmiTWJdGREQ==)
https://docs.oracle.com/error-help/db/ora-12541/] [n/a]
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:63) ~[hibernate-core-6.6.8.Final.jar!/:6.6.8.Final]
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108) ~[hibernate-core-6.6.8.Final.jar!/:6.6.8.Final]
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94) ~[hibernate-core-6.6.8.Final.jar!/:6.6.8.Final]
        at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:116) ~[hibernate-core-6.6.8.Final.jar!/:6.6.8.Final]
1 Like

Check if listener is started or not using below command -

docker exec -it <container_name> lsnrctl status

I am getting below resp.

Containers are for isolation. When using localhost within a container, it’s only within the container, not on the host. And Docker Desktop even adds a Linux VM as an additional layer. So you need to use a different IP to connect to, not localhost or 127.0.0.1.

Thanks @bluepuma77 as per your suggestion I started oracle db on some other ip/port now its working fine.
image

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.