本文介绍了邮递员无法访问本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在公司环境中,所以我必须使用代理来访问服务器.这在邮递员和浏览器中运行良好.我无法访问的是邮递员中的本地主机,但我可以在浏览器中访问本地主机.

I am in a corporate env so I have to use a proxy to reach servers. This works well in postman and in browsers. What I can't reach is localhost in postman but I can reach localhost in the browser.

我正在为 Linux 版本 6.0.9 运行 Postman.我尝试在全局代理和系统代理打开以及打开和未打开的情况下到达 localhost:9082/rest/myapi .... 和 127.0.0.1:9082/rest/myapi.在所有情况下,我都无法访问本地主机.

I am running Postman for Linux Version 6.0.9. I have tried reaching localhost:9082/rest/myapi.... and 127.0.0.1:9082/rest/myapi with both global proxy and system proxy turned on and with either turned on and with non turned on. In all cases I am not able to reach localhost.

我得到的响应是来自代理服务器的错误页面!不知何故,呼叫在网络上发出,而不是保留在我的机器上.

What I get as an response is an error page from the proxy server! Someway the call gets out on the network instead of being kept on my machine.

邮递员控制台:

我的请求标头是:

Cache-Control →no-cache
Connection →Keep-Alive
Content-Length →986
Content-Type →text/html; charset=utf-8
Pragma →no-cache
Proxy-Connection →Keep-Alive

我的响应头是:

cache-control:"no-cache"
pragma:"no-cache"
content-type:"text/html; charset=utf-8"
proxy-connection:"Keep-Alive"
connection:"Keep-Alive"
content-length:"986"

我的响应正文是一个 html 页面.

My response body is an html page.

如何使用 postman 调用 localhost 工作?

How can I make a call to localhost work with postman?

推荐答案

我找到了一个临时解决方案:

I found a temporary solution:

在终端中,进入 postman 安装目录并添加:

In terminal, go to the directory where postman is installed and add:

machine@dev:~/Documents/Postman$ export NO_PROXY=localhost,127.0.0.1
machine@dev:~/Documents/Postman$ ./Postman

这将使对本地主机的调用工作.

This will make calls to localhost work.

我在 Windows 机器上发现了类似的问题这里

I found a similar problem on Windows machines here

这篇关于邮递员无法访问本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:43