Skip to content

Commit 589385f

Browse files
committed
Not allowed to use localhost
1 parent ce4cc4d commit 589385f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

profiler/test/Datadog.Profiler.IntegrationTests/Helpers/TestApplicationRunner.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ private string GetApplicationPath()
153153
}
154154

155155
// Use port 0 so Kestrel binds an OS-assigned free port and avoids the TOCTOU race
156-
// of pre-picking a port. The actual bound URL is parsed from stdout after the run.
157-
var arguments = $"--timeout {TestDurationInSeconds} --urls http://localhost:0";
156+
// of pre-picking a port. Bind to 127.0.0.1 explicitly: Kestrel rejects "localhost:0"
157+
// with InvalidOperationException ("Dynamic port binding is not supported when binding
158+
// to localhost"). The actual bound URL is parsed from stdout after the run.
159+
var arguments = $"--timeout {TestDurationInSeconds} --urls http://127.0.0.1:0";
158160
if (!string.IsNullOrEmpty(_commandLine))
159161
{
160162
arguments += $" {_commandLine}";

0 commit comments

Comments
 (0)