got: got request for host in hosts file throws ENOTFOUND
Describe the bug
- Node.js version: 12.16.2 (also tested with 14.0.0)
- OS & version: windows 10
Actual behavior
Attempting a got
request against a host which is registered in my hosts files fails with an ENOTFOUND; where doing an https.get
for the same host and path does not.
This used to work with got 10, but got 10 hangs on node 12 on an ubuntu 14 machine, which happens to be my target for this project 😕
Expected behavior
Should be able to retrieve data from a server by hostname according to system hosts file
Code to reproduce
(not so much code as steps):
- set up an http server listening on 127.0.0.1
- create a hostfile rebind for some other hostname
- attempt
got
to that server
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20
I’ve raised https://github.com/szmarczak/cacheable-lookup/issues/24 – please let me know if you need more info (:
I originally left out code because the situation is easy enough to replicate, but specific to the host system; however, as per your request, here’s a full set of steps:
1. update \windows\system32\drivers\etc\hosts to contain:
2. create a new project:
3. add the
app.js
file:4. update package.json, adding the ‘start’ script:
5. Run it
6. Create a batch file:
7. Run the batch file