I'm on a Mac and I'm attempting to run my k6 script against http://localhost:4200
(angular app) locally.
The angular app is running and I can access it via the browser and using curl
.
My k6 script has the base URL set to http://localhost:4200
. However, all requests are being made to http://127.0.0.1:4200
instead which is denied by MacOS.
How do I force k6 to NOT rewrite localhost
to the loopback address?
EDIT
Adding various outputs of curl -vv
.
localhost:4200
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 4200 (#0)
> GET / HTTP/1.1
> Host: localhost:4200
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: text/html; charset=utf-8
< Accept-Ranges: bytes
< Content-Length: 942
< ETag: W/"3ae-UQojFJZul+b6hEhgbvnN6wFCVuA"
< Date: Thu, 20 Jan 2022 21:38:55 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MyApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="assets/scripts/apm.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/images/apple-touch-icon.png">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/images/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="stylesheet" href="styles.css"></head>
<body>
<app-root></app-root>
<script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="styles.js" defer></script><script src="vendor.js" type="module"></script><script src="main.js" type="module"></script></body>
</html>
* Connection #0 to host localhost left intact
* Closing connection 0
127.0.0.1:4200
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connection failed
* connect to 127.0.0.1 port 4200 failed: Connection refused
* Failed to connect to 127.0.0.1 port 4200: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 127.0.0.1 port 4200: Connection refused
EDIT 2
Hosts file
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal