简体   繁体   English

Vagrant运行DSTK拒绝端口8080的连接

[英]Vagrant running DSTK refuses connections at port 8080

I'm very new to the land of virtual machines and vagrant, so please forgive my general ignorance about all of this. 我是虚拟机和流浪汉的新手,所以请原谅我对所有这一切的无知。

The other day, I downloaded DSTK vagrant box and followed the instructions on the documentation page to get it set up so I could run many, many thousands of requests through it on my local machine rather than bombarding the public server (and also, it should be faster; and also, DSTK is down at the moment so it was the only option). 前几天,我下载了DSTK vagrant box并按照文档页面上的说明进行设置,这样我就可以在我的本地机器上通过它运行成千上万的请求而不是轰炸公共服务器(而且,它应该更快;而且,DSTK目前正在下降所以它是唯一的选择)。

After many hours of waiting for vagrant to add and init the box on my tired old hard drive, it worked! 经过几个小时的等待流浪汉add并在我累旧的硬盘驱动器上init盒子,它工作了! I used curl to make a few requests, got the expected responses, and patted myself on the back. 我用curl做了一些请求,得到了预期的响应,并拍了拍自己的背面。 I closed my terminal and put away my computer and drank beer. 我关上了我的终端,收起电脑,喝了啤酒。

... And then, the next morning, this happened: ......然后,第二天早上,这发生了:

$ curl -d "Joe Biden" "localhost:8080/text2people"
curl: (7) Failed to connect to localhost port 8080: Connection refused

I can't work out why. 我无法理解为什么。 I tried vagrant suspend; vagrant up 我试过vagrant suspend; vagrant up vagrant suspend; vagrant up . vagrant suspend; vagrant up Same thing. 一样。 vagrant halt; vagrant up vagrant halt; vagrant up . vagrant halt; vagrant up Same thing. 一样。 When I've halted vagrant and run 'vagrant up' again, this appears in the readout, which makes me think it ought to be working. 当我停止流浪汉并再次“流浪”时,这会出现在读数中,这让我觉得它应该有效。

==> default: Forwarding ports...
default: 80 => 8080 (adapter 1)
default: 22 => 2222 (adapter 1)

I can run vagrant ssh and get in, look around, and I see that all the files are in the right right place. 我可以运行vagrant ssh并进入,环顾四周,我看到所有文件都在正确的位置。

I suppose I could remove the box and re-add it, but it really did take hours to add and init and now I'm running up against a deadline where I need to it work, and I imagine there is a very simple thing of which I am not aware that is causing my problem. 我想我可以删除盒子并重新添加它,但它确实需要几个小时来addinit ,现在我正在运行我需要它工作的截止日期,我想有一个非常简单的事情我不知道这是导致我的问题。 Google has thus far been unhelpful, probably because of how unfamiliar I am with vagrant, generally. 到目前为止,谷歌一直没有帮助,可能是因为我对流浪汉有多么不熟悉。

I have just encountered the same problem, in my case the solution was to ensure that the following line is not commented on the Vagrantfile: 我刚遇到同样的问题,在我的情况下,解决方案是确保在Vagrantfile上没有注释以下行:

config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" config.vm.network“forwarded_port”,guest:80,host:8080,host_ip:“127.0.0.1”

So it's not a problem with vagrant or virtualbox at all. 所以它根本不是vagrant或virtualbox的问题。

It turns out I just didn't stop to think about whether curl could be the culprit, and when I got around to this again, fixing it was as simple as curl "127.0.0.1:8080/..." . 事实证明我只是没有停下来思考curl是否可能是罪魁祸首,当我再次解决这个问题时,修复它就像curl "127.0.0.1:8080/..."一样简单。 Apparently curl (or at least the native Mac OSX implementation) doesn't like localhost . 显然curl(或至少是原生的Mac OSX实现)不喜欢localhost

I did try to Google about it for a few minutes, though, and I came across my own un-answered question, which was sort of a bummer—so in case anybody else ever has this problem, here's your fix. 我确实尝试了谷歌几分钟,我遇到了我自己未回答的问题,这有点无聊 - 所以如果其他人有这个问题,这是你的修复。

curl "localhost:8080/text2people" -d "Joe Biden"
curl: (7) Failed to connect to localhost port 8080: Connection refused

curl "127.0.0.1:8080/text2people" -d "Joe Biden"
[
  {
    "title": "",
    "gender": "m",
    "start_index": 0,
    "first_name": "Joe",
    "end_index": 9,
    "surnames": "Biden",
    "ethnicity": {
      "percentage_american_indian_or_alaska_native": 0.0,
      "rank": 114852,
      "percentage_two_or_more": 0.0,
      "percentage_of_total": 5.0e-05,
      "percentage_hispanic": 0.0,
      "percentage_white": 96.45,
      "percentage_black": 0.0,
      "percentage_asian_or_pacific_islander": 0.0
    },
    "matched_string": "Joe Biden"
  }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM