ORA-12514 when connecting to an Oracle database container
ORA-12514: Cannot connect to database. Service ... is not registered with the listenerShort answer
ORA-12514 means the listener got a request for a service name it does not know. With an Oracle container it is usually one of three things: the database is still starting, the service name in your connection string is wrong (for the Free image it is FREEPDB1, not FREE), or you used localhost from another container.
Fix it fast
1Find out which cause you have
Ask the listener inside the container which services it knows, and look for READY.
docker exec -it oracle lsnrctl services2Match what you see, then jump to its fix
What does the error look like?
ORA-12514: Cannot connect to database. Service ... is not registered with the listenerService ... is not registered with the listener at host:port
Cause 1 of 3
The database is still starting
1Check
Oracle lists a just-started database as one that has not finished registering with the listener. The image logs a ready banner when it is done.
docker logs oracle 2>&1 | grep "DATABASE IS READY TO USE"2Fix
Wait for the banner, or give the container a healthcheck and make dependents wait for it.
services:
oracle:
image: gvenzl/oracle-free
healthcheck:
test: ["CMD", "healthcheck.sh"]
interval: 10s
retries: 303Verify
The log shows the banner and lsnrctl lists the service as READY.
docker exec oracle lsnrctl servicesConfirmed by github.com
Cause 2 of 3
The service name in the connection string is wrong
1Check
Compare the name after the slash in your connection string with what the listener and the database report.
docker exec -it oracle lsnrctl services
# inside sqlplus: SELECT name FROM v$services;2Fix
Use a name the listener lists. For the Free image the default pluggable database is FREEPDB1, so the connection target is that service, not the instance name FREE.
sqlplus test/test@//localhost:1521/FREEPDB13Verify
The login succeeds.
echo 'select 1 from dual;' | sqlplus -s test/test@//localhost:1521/FREEPDB1Confirmed by docs.oracle.com
Cause 3 of 3
Another container connects to localhost
1Check
Inside a Compose network, services reach each other by service name; localhost there is the app container itself.
docker compose exec app printenv DB_HOST2Fix
Use the service name as host and the container port 1521.
jdbc:oracle:thin:@//oracle:1521/FREEPDB13Verify
Restart the app and check its connection log.
docker compose up -d app && docker compose logs --tail 20 appConfirmed by docs.docker.com
How do I stop it coming back?
- Add a healthcheck and depends_on with condition service_healthy for apps that need the database.
- Keep host, port and service name in one environment file.
- Mount a volume at /opt/oracle/oradata so a restart does not rebuild the database.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix