testcontainers/testcontainers-java · warning
Unexpected error occurred - will proceed to try to wait…
Error message
Unexpected error occurred - will proceed to try to wait anyway
What it means
HttpWaitStrategy builds a formatted URI for logging and any RuntimeException thrown while doing so is caught and logged at WARN level. This is a non-fatal diagnostic: the strategy deliberately does not let a logging failure block the wait loop, so it proceeds to attempt the HTTP connection anyway. The underlying exception is attached to the warning for diagnosis.
Solutions
- Inspect the attached exception stack trace to see which URI formatting step failed
- Set an explicit port via waitingFor(new HttpWaitStrategy().forPort(8080)) so the raw URI port fallback is not needed
- Ignore it if the container still becomes ready — the wait proceeds normally after this warning
Example fix
// before new HttpWaitStrategy().forStatusCode(200) // relies on raw URI port parsing // after new HttpWaitStrategy().forPort(8080).forStatusCode(200)
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure an explicit port is configured so raw URI parsing is not needed
if (waitStrategy instanceof HttpWaitStrategy) {
((HttpWaitStrategy) waitStrategy).forPort(8080);
} Try / catch
// This warning is internal to the library; callers need no handling.
// If wrapping waits yourself:
try {
waitUntilReady(container);
} catch (RuntimeException e) {
// log and continue waiting, mirroring the strategy's own behavior
log.warn("wait failed, continuing", e);
} Prevention
- Always set forPort(...) explicitly on HttpWaitStrategy
- Treat this warning as noise unless containers fail to become ready
- Check the attached stack trace when diagnosing unusual URI schemes
When it happens
Trigger: waitUntilReady catches any RuntimeException from constructing the log message (e.g. URI formatting/port extraction on a raw URI without a port). The message appears whenever that formatting code throws, regardless of whether the actual HTTP check succeeds.
Common situations: Containers exposing URIs with unusual formats (raw URIs without an explicit port, IPv6 literals, custom wait.forHttp paths); typically harmless noise during container startup with HttpWaitStrategy.
Related errors
- you cannot specify a value smaller than 1 ms
- HTTP response code was
- Response: did not match predicate
- Timed out waiting for URL to be accessible
- : No exposed ports or mapped ports - cannot wait for status
AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12).
Data as JSON: /api/errors/538362bb74a51958.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/testcontainers/containers/wait/strategy/HttpWaitStrategy.java:247
try {
// Un-map the port for logging
int originalPort = waitStrategyTarget
.getExposedPorts()
.stream()
.filter(exposedPort -> rawUri.getPort() == waitStrategyTarget.getMappedPort(exposedPort))
.findFirst()
.orElseThrow(() -> new IllegalStateException("Target port " + rawUri.getPort() + " is not exposed"));
log.info(
"{}: Waiting for {} seconds for URL: {} (where port {} maps to container port {})",
containerName,
startupTimeout.getSeconds(),
uri,
rawUri.getPort(),
originalPort
);
} catch (RuntimeException e) {
// do not allow a failure in logging to prevent progress, but log for diagnosis
log.warn("Unexpected error occurred - will proceed to try to wait anyway", e);
}
// try to connect to the URL
try {
retryUntilSuccess(
(int) startupTimeout.getSeconds(),
TimeUnit.SECONDS,
() -> {
getRateLimiter()
.doWhenReady(() -> {
try {
final HttpURLConnection connection = openConnection(uri);
connection.setReadTimeout(Math.toIntExact(readTimeout.toMillis()));
// authenticate
if (!Strings.isNullOrEmpty(username)) {
connection.setRequestProperty(
HEADER_AUTHORIZATION,View on GitHub (pinned to 8e549514e3)