Skip to content
New issue

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

Desktop App not honoring /etc/hosts file -- returning 404s #2369

Closed
bkvaughan opened this issue Sep 29, 2016 · 65 comments
Closed

Desktop App not honoring /etc/hosts file -- returning 404s #2369

bkvaughan opened this issue Sep 29, 2016 · 65 comments
Assignees
Milestone

Comments

@bkvaughan
Copy link

This issue started after moving from the Chrome App to the Mac App. In the Chrome App everything behaves as expected, however, in the Mac App all of my calls now return 404s. After troubleshooting the only thing I can think that's different is the app and how it may be interacting with the /etc/hosts file. The below Request Headers/Response Headers/Response Body are taken from the Mac App.

  1. Postman Version: 4.7.2
  2. App (Chrome app or Mac app): Mac app
  3. OS details: OS X El Capitan 10.11.6
  4. Is the Interceptor on and enabled in the app: Interceptor off
  5. Did you encounter this recently, or has this bug always been there: Recently
  6. Expected behaviour: Postman should honor /etc/hosts file
  7. Console logs (http://blog.getpostman.com/2014/01/27/enabling-chrome-developer-tools-inside-postman/ for the Chrome App, View->Toggle Dev Tools for the Mac app):

Request Headers:
cache-control:"no-cache"
Postman-Token:"a27758c0-bf38-4521-8135-2edd442ccd4c"
Host:"api.maila.dev.naiadsystems.com"
Connection:"keep-alive"
Accept:"application/json, text/plain, /"
Origin:"https://admin.maila.dev.naiadsystems.com"
User-Agent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
Referer:"https://admin.maila.dev.naiadsystems.com/variables/2"
Accept-Encoding:"gzip, deflate, sdch"
Accept-Language:"en-US,en;q=0.8"
Cookie:"PHPSESSID=gng7k6dh5nh4q4ogk3tsn8mis0; sakey=saede52e5973731352"
Content-Type:"application/json"

Response Headers:
Date:"Thu, 29 Sep 2016 18:09:50 GMT"
Server:"Apache/2.4.10 (Debian)"
Content-Length:"308"
Keep-Alive:"timeout=5, max=100"
Connection:"Keep-Alive"
Content-Type:"text/html; charset=iso-8859-1"

Response Body:

<title>404 Not Found</title>

Not Found

The requested URL /v1/entitytypes was not found on this server.


Apache/2.4.10 (Debian) Server at api.maila.dev.naiadsystems.com Port 80
@a85 a85 added the Usability label Sep 30, 2016
@DuskoV
Copy link

DuskoV commented Dec 4, 2016

+1 I have a custom entry in hosts file, and native Postman is not figuring it out (it's saying domain not found, instead of figuring setting from /etc/hosts)

@afrozenpeach
Copy link

I'm having the same issue on the Windows version of Postman

@vanquang9387
Copy link

Same issue with Postman App on Windows

@tobeorla
Copy link

Yep, happens to me too. Windows 10. Guess it's time to uninstall it and keep using the extension.

@democraci
Copy link

Same issue on my windows 7, curl not honoring host file too

@jan-carreras
Copy link

Same with OSX El Capitan 10.11.6.

@josecols
Copy link

Same with Version 4.10.7 on macOS Sierra 10.12.3

@numaanashraf numaanashraf added feature and removed bug labels Apr 12, 2017
@numaanashraf
Copy link
Member

numaanashraf commented Apr 12, 2017

Postman native apps, do not have support for /etc/hosts at the moment. We are working on this and will post updates here.

@udayms
Copy link

udayms commented Apr 13, 2017

Weird... My postman collection was working fine with the entry in /etc/hosts file till the latest update. After that, only ip access works.... in my case, my api server is running on a vm on my mac. I have been able to use postman for the last many months to connect to my vm through the name in my hosts file.

@cenxun
Copy link

cenxun commented Jun 12, 2017

Same issue

Version 5.0.0
win7 / x86-64
Chrome 59.0.3071.86

@okonomiyaki3000
Copy link

okonomiyaki3000 commented Jun 12, 2017

Guys, if you have the same issue, be sure to +1 the original post.

Also, v5.0.0 now and still nothing on this issue? Come on, guys, don't make me use Insomnia.

@xbot
Copy link

xbot commented Jul 12, 2017

Same issue

Native APP
Version: 5.0.2
Mac OS 10.12.5

@kingio
Copy link

kingio commented Jul 17, 2017

@okonomiyaki3000 i switched to insomnia as postman is useless without hosts file support. It's quite bad vs postman but at least works.

@lietu
Copy link

lietu commented Jul 21, 2017

The issue does not seem to be limited to only native apps, I'm using Postman via Chrome's Apps and it also does not use my c:\windows\system32\drivers\etc\hosts -configuration

@flyinprogrammer
Copy link

flyinprogrammer commented Sep 9, 2017

edit: turns out idk what i'm doing. /etc/hosts works just fine on postman v5.2.0 ubuntu 17.04
real annoying 😢

@okonomiyaki3000
Copy link

How can a bug like this go unfixed for a year?

@tobeorla
Copy link

tobeorla commented Oct 2, 2017

@okonomiyaki3000 Author uses linux for development, so gives a fuck on other "supported" platforms

@okonomiyaki3000
Copy link

Congratulations on v5.3! The new features look really great! I look forward to using them someday if this glaring, year-old bug ever gets fixed!

@crabmusket
Copy link

crabmusket commented Nov 10, 2017

Same issue, I think, on Ubuntu 16.04 with version 5.3.2. I get no response though, the request just loads indefinitely. It works fine with the browser extension so I guess I'll use that until this is fixed.

EDIT: I might be having a different issue. It seems all my requests are hanging. Going back to version 4.10.7 fixed that. I'm working around the hostfile issue by making all requests to my local IP address, then adding a Host header so my server can tell which of the sites from my hostfile I want.

@andrefatchip
Copy link

Also affected by this on KDE neon. As well using chrome app which will do the trick intermediate.

@ghost
Copy link

ghost commented Feb 22, 2018

I can't understand how such a critical bug can manage to stay unresolved for more than a year!
Postman is used by developers, developers use hosts file to easily manage dev environments!
Everyone is switching to Insomnia because of this, and yet here we are in 2018 and this bug is still here.

@okonomiyaki3000
Copy link

@jc-vrvd It's over a year and half already. But, you know, it can be hard to get something like this to work correctly. Don't be fooled by the fact that every other piece of software in existence handles this without issue. It is very hard.

@matias-favale
Copy link

Same here. OS X High Sierra 10.13.6 and postman 6.7.2, but it was working before, not sure which version broke it.

@okonomiyaki3000
Copy link

@mafavale You may be confusing the Chrome app with the standalone version. The Chrome app always worked, the standalone (probably) never did.

@yansern
Copy link

yansern commented Feb 21, 2019

I got around this issue by setting up a local proxy and configure postman to use that local proxy that honors hosts file.

@codenirvana
Copy link
Member

codenirvana commented Feb 25, 2019

Hello everyone,

I tried to reproduce this in all the three platforms (phew… that was tedious) and seems like /etc/hosts is working fine for every platform. I added a local server to run on port 3000 and added www.google.com to the hosts file to replace www.google.com with localhost!

I took screenshots for each platform and have appended to this thread.

Understandably, there is something going wrong somewhere for those who are facing issues with Postman not honoring /etc/hosts file. I think we need to deep-dive into one or more such cases. If anyone is interested, please message me and we can get in a screen sharing session to solve this.

Overall, I think we need the following checked before it works:

  1. Ensure you have latest Postman native app (v6.7.3 or higher) (keep a screenshot of [wrench icon on top right] -> settings -> "about" tab)
  2. Download this NodeJS script and start the same (this starts a local server at port 3000)
  3. Use curl to make a call to this localhost:3000 using --verbose and provide a copy of that (let's call it test sample)
  4. Use Postman to make a call to localhost:3000 and send the saved response.
  5. Then add the following line to your /etc/hosts file (for Windows C:\Windows\System32\Drivers\etc\hosts): 127.0.0.1 www.google.com
  6. Use curl to make a call to this www.google.com:3000 using --verbose and provide a copy of that (let's call it working sample)
  7. Use Postman to make a call to www.google.com:3000 and send the saved response.

If your /etc/host works then the two sample curl command output body would be nearly identical.

Screenshots of /etc/hosts working:

MacOS

macos

Windows

windows2
windows1

Linux

linux1
linux2

@codenirvana codenirvana self-assigned this Feb 25, 2019
@okonomiyaki3000
Copy link

@codenirvana lol, how nice. You realize that's not where the hosts file resides on either Windows or Mac, right? Would it be so difficult to use the correct file for each system?

@codenirvana
Copy link
Member

@okonomiyaki3000 Thanks for pointing out, updated the Step 5.

@shamasis
Copy link
Member

shamasis commented Feb 26, 2019

@okonomiyaki3000 can you help with trying these steps and maybe even get into a call or suggest something specific that may help us reproduce this? I have been feeling pretty stupid myself for not being able to reproduce this. I am almost sure that I am missing something or there is something specific about the installation where there are issues. 😭

@shamasis
Copy link
Member

Just wanted to reach out to everyone in this thread who were having issues with host file. Any way we can work together and reproduce this issue as discussed in
#2369 (comment)

Maybe then we can keep this issue as closed and circle back when we have fresh issues.

@a85
Copy link
Contributor

a85 commented Mar 25, 2019

@okonomiyaki3000 If it's not feasible to keep a constructive tone when you get your hands on a keyboard then please refrain from commenting here. There are hundreds of comments and issues on this tracker and reading through crappy comments just creates more noise.

@a85 a85 closed this as completed Mar 25, 2019
@matt-gribben
Copy link

This is still an issue for me on Windows 10 & v7.0.7

@vikaspro90
Copy link

vikaspro90 commented Apr 19, 2019

@codenirvana Thanks for the steps. The issue is still present. I am using Version 7.0.7 on Mac.
To be specific,

  • It respects any entries that point to 127.0.0.1 (does not matter whether a new line is added in the file or an already existing line is used eg. 127.0.0.1 localhost custom.host.com)
  • It does not respect pointing to other IP addresses.

@caseyoconnor10
Copy link

caseyoconnor10 commented May 9, 2019

I set Use System Proxy = Off and my Host file is being used now. I am on Postman v7.0.9 but all my entries are 127.0.0.1 in the hostfile as mentioned.

@codenirvana
Copy link
Member

@vikaspro90 Please check the attached screenshot.
Can you try configuring the same IP for postman-echo.com (screenshot)?

Screenshot 2019-06-18 at 3 08 38 AM

@devonjs
Copy link

devonjs commented Sep 11, 2019

Postman v7.5.0 on Windows, in Settings was able to point the Global Proxy Configuration to the a specified IP address under Proxy Server

@ostrolucky
Copy link

ostrolucky commented Mar 4, 2020

In my case it looks like Postman is not honoring /etc/hosts when there is DNS record for given hostname registered. MacOS here.

@hardy-liu
Copy link

In my case it looks like Postman is not honoring /etc/hosts when there is DNS record for given hostname registered. MacOS here.

same issue. It seems Postman cached the dns record for a while. After I modified the hosts file. The Postman stille use the previous dns record for that domain. But after a few moment, it will use the record in hosts file. I wonder if there is a feature i can manually flush the dns cache in Postman.

@sberney
Copy link

sberney commented Apr 30, 2020

This is still occurring on the Postman App, but not on the chrome extension. I'm on Windows. Instead of remapping addresses to localhost, I am remapping addresses to miscellaneous LAN IPs.

It may have something to do with the name of the network name of the machine, because technically my machine is me.redacted.net, and Postman Native is querying them.redacted.net, where my machine and the target machine both believe they are on redacted.net, but local DNS does not have the mapping. However them.classified.com does not resolve in Postman Native, only in the Chrome App (and in other browsers).

@alhacen
Copy link

alhacen commented Jul 8, 2020

I cleared my dns cache and it starts honoring hosts file
https://documentation.cpanel.net/display/CKB/How+To+Clear+Your+DNS+Cache

@kevinsproles
Copy link

Hosts file is working for me on MacOS, after I went into Settings > General and turned off SSL Certificate Verification, since I'm using a self-signed cert.

Postman for Mac. Version 7.7.3. OS X 19.6.0.

(not sure if it was also after i cleared my dns cache as @alhaqhassan mentioned)

@jhandsaker
Copy link

Hopefully this helps someone else. I'm using the Windows Native App and it wasn't honoring my host file. I had postman setup to use a proxy. It was hitting the proxy first before checking my host file. I added a Proxy Bypass in Postman for the same entries I had in my host file and then it worked.

@tolgaulas
Copy link

tolgaulas commented Nov 29, 2020

Native app (7.36.0) on windows 10 and still custom entry on hosts file is not resolved despite clearing dns cache.

@ruan11223344
Copy link

ruan11223344 commented Dec 17, 2020

don't customize the host header!!!!!
image

@aliaksander-samuseu
Copy link

aliaksander-samuseu commented May 20, 2021

Same issue here.. How can it still be the case after 5 years?
On Ubuntu 18, the latest stable Postman version - in /etc/hosts I override an existing web service's DNS name to point at a host on my local network which runs a mock http server. Then I try to use Postman's intercept feature, while configuring my browser to use 127.0.0.1:5555 as a proxy. But it never gets to my local host, it tries to reach the real thing on the Internet. The app doesn't even have any visible logs, so I spent a few hours trying to understand what's going on.

In Burp it works without any issue, it honors hosts file, and even allows additional overrides inside it as well..

@ToffeeLu
Copy link

One tip for Windows user, try "Run as Administrator", now it can read hosts successfully

@Gohsato
Copy link

Gohsato commented Mar 7, 2022

I was having this issue too. For me, turning off the Connection: keep-alive header fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests