We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.0.8+2a405f691e80725fe0b97b93afd3b8cfed13fa5f
Linux 6.1.0-12-amd64 x86_64 unknown
Run the following code that creates a hello-world express sever whith and end point and fetch it using "localhost". (I'm using express 4.18.2)
var express = require("express"); var app = express(); app.get("/api", function (req, res) { res.send("hola"); }); var server = app.listen(8000, "127.0.0.1"); const url = "http://localhost:8000"; async function make_request() { let response = await fetch(url + "/api"); const text = await response.text(); console.log(text); server.close(); } make_request();
Under node it returns "hola".
ConnectionRefused: Unable to connect. Is the computer able to access the url? path: "http://localhost:8000/api"
If you change the line with the server url to
const url = "http://127.0.0.1:8000";
everything works in bun as expected!
The text was updated successfully, but these errors were encountered:
This doesn't work on Node either. I get this in Node:
➜ npx ts-node test.ts TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:14152:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) { cause: Error: connect ECONNREFUSED ::1:8000 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) { errno: -61, code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 8000 } }
Works in both Bun and Node if you remove the "127.0.0.1" from the listen call.
"127.0.0.1"
listen
Sorry, something went wrong.
Strange. Seems to be something related to the network configuration in my machine. I'm using node 20.9.0
cat /etc/networks gives
default 0.0.0.0 loopback 127.0.0.0 link-local 169.254.0.0
However, for some reason bun and node are resolving the host address in a different way!
My operative system is Debian 12
We will fix this, duplicate of #1425
No branches or pull requests
What version of Bun is running?
1.0.8+2a405f691e80725fe0b97b93afd3b8cfed13fa5f
What platform is your computer?
Linux 6.1.0-12-amd64 x86_64 unknown
What steps can reproduce the bug?
Run the following code that creates a hello-world express sever whith and end
point and fetch it using "localhost".
(I'm using express 4.18.2)
What is the expected behavior?
Under node it returns "hola".
What do you see instead?
ConnectionRefused: Unable to connect. Is the computer able to access the url?
path: "http://localhost:8000/api"
Additional information
If you change the line with the server url to
everything works in bun as expected!
The text was updated successfully, but these errors were encountered: