无法使用命令提示符下的cURL连接到localhost [英] Cannot connect to localhost with cURL on Command Prompt

查看:1693
本文介绍了无法使用命令提示符下的cURL连接到localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在硬盘上安装了 cURL ,以便用我的localhost进行测试(在命令提示符下)。但是我无法连接到任何端口。您可以在下面看到目录和我的输入:

I've just installed cURL on my hard-drive in order to use for testing with my localhost (on the command prompt). However I cannot connect to any port. You can see the directory and my input below:


C:\ Users\me\curl\src> curl -v http:// localhost:9000

给了我:



  • 重建网址: http:// localhost:9000 /

  • 不支持名称查找超时

  • 尝试:: 1 ...

  • 设置TCP_NODELAY

  • 尝试127.0.0.1 ...

  • TCP_NODELAY set

  • connect to :: 1 port 9000 failed:Connection refused

  • connect to 127.0.0.1 port 9000 failed:Connection refused

  • 无法连接到localhost端口9000:连接被拒绝

  • 关闭连接0卷曲:(7)无法连接到localhost端口9000:连接被拒绝

  • Rebuilt URL to: http://localhost:9000/
  • timeout on name lookup is not supported
  • Trying ::1...
  • TCP_NODELAY set
  • Trying 127.0.0.1...
  • TCP_NODELAY set
  • connect to ::1 port 9000 failed: Connection refused
  • connect to 127.0.0.1 port 9000 failed: Connection refused
  • Failed to connect to localhost port 9000: Connection refused
  • Closing connection 0 curl: (7) Failed to connect to localhost port 9000: Connection refused

也许我笑uld已经添加了我正在使用IntelliJ并且已经在硬盘驱动器上启用了cURL(允许我从任何目录访问它);提示我尝试以下操作:

Perhaps I should have added that I am using IntelliJ and have since enabled cURL on the harddrive (allowing me to access it from any directory); prompting me to try the following:


C:\ Users\me\scala\ play \ my-project> curl -v http:// localhost:9000 /

返回:



  • 不支持名称查找超时

  • 尝试:: 1 ...

  • TCP_NODELAY设置

  • 连接到:: 1端口9000失败:连接被拒绝

  • 尝试127.0.0.1 ...

  • TCP_NODELAY设置

  • 连接到127.0.0.1端口9000失败:连接被拒绝

  • 无法连接到localhost端口9000:连接被拒绝

  • 关闭连接0卷曲:(7)无法连接到localhost端口9000 :连接被拒绝

  • timeout on name lookup is not supported
  • Trying ::1...
  • TCP_NODELAY set
  • connect to ::1 port 9000 failed: Connection refused
  • Trying 127.0.0.1...
  • TCP_NODELAY set
  • connect to 127.0.0.1 port 9000 failed: Connection refused
  • Failed to connect to localhost port 9000: Connection refused
  • Closing connection 0 curl: (7) Failed to connect to localhost port 9000: Connection refused

所以似乎端口9000没有打开。我现在认为这需要在intelliJ中配置 - 这里 - 但这看起来好像只支持终极版。这可能是我遇到的问题的原因。它可能对其他人有帮助,但如果有人确实有更多信息,那么确定这一点会很好。

So it seems that port 9000 is not open. And I am now thinking that this needs to be configured within intelliJ - here - but this looks as though it is only supported on the Ultimate Edition. This might be the cause of the issue that I am having. It may be helpful to others but it would be good to be sure of this if anyone does have any more information.

推荐答案

这个表示您的应用程序尚未启动(因此它实际上并未在端口9000上侦听)

This means that your application is not started yet (so it isn't actually listening on port 9000)

您应该在IntelliJ中添加运行配置(运行> 编辑配置> + > 播放2 App )并在进行curl调用之前运行它。

You should add a run configuration in IntelliJ (Run > Edit Configurations > + > Play 2 App) and run it before doing your curl call.

启动应用程序的另一种方法是在项目文件夹中打开终端,然后运行 sbt run

Another way to start your application is just to open a terminal in your project folder, and run sbt run.

这篇关于无法使用命令提示符下的cURL连接到localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆