简体   繁体   English

尝试运行Google App Engine程序时无法连接到localhost:8080

[英]Can't connect to localhost:8080 when trying to run Google App Engine program

I'm trying to run the Google App Engine Python 2.7 Hello World program and view it in a browser via Google App Engine Launcher. 我正在尝试运行Google App Engine Python 2.7 Hello World程序,并通过Google App Engine启动器在浏览器中查看它。 I followed the install and program instructions to the letter. 我按照安装和程序说明进行操作。 I copied and pasted the code in the instructions to the helloworld.py file and app.yam1 and verified that they are correct and in the directory listed as the application directory. 我将指令中的代码复制并粘贴到helloworld.py文件和app.yam1中,并验证它们正确无误,并在列为应用程序目录的目录中进行了验证。 I hit run on the launcher and it runs with no errors, although I get no sign that is has completed (orange clock symbol next to app name). 我在启动器上运行了run,并且运行没有错误,尽管我没有收到任何已完成的标志(应用程序名称旁边的橙色时钟符号)。 I get the following from the logs: 我从日志中得到以下内容:

  • Running dev_appserver with the following flags: --skip_sdk_update_check=yes --port=8080 --admin_port=8000 Python command: /opt/local/bin/python2.7 运行带有以下标志的dev_appserver:--skip_sdk_update_check = yes --port = 8080 --admin_port = 8000 Python命令:/opt/local/bin/python2.7

When I try to open in the browser via the GAE Launcher, the 'browse' icon is grayed out and the browser won't open. 当我尝试通过GAE启动器在浏览器中打开时,“浏览”图标显示为灰色,并且浏览器无法打开。 I tried opening localhost:8080 in Firefox and Chrome as the tutorial suggests, but I get unable to connect errors from both. 如本教程所述,我尝试在Firefox和Chrome中打开localhost:8080,但无法同时连接两者。

How can I view Hello World in a browser? 如何在浏览器中查看Hello World? Is there some configuration I need to make on my machine? 我需要在机器上进行一些配置吗?

I had the same problem. 我有同样的问题。 This seemed to fix it: 这似乎解决了它:

cd to google_appengine, run cd到google_appengine,运行

python dev_appserver.py --port=8080 --host=127.0.0.1 /path/to/application python dev_appserver.py --port = 8080 --host = 127.0.0.1 / path / to / application

at this point there is a prompt to allow updates on running, I said Yes. 此时,系统会提示您允许运行中的更新,我说是。

At this point the app was running as it should, also when I quit this and went in using the launcher again, that worked too. 此时,该应用程序已按预期运行,并且当我退出并再次使用启动器时,该应用程序也正常运行。

I have to manually start python and make it point to my app folder, for instance in a command line window on Windows I am using python. 我必须手动启动python,并将其指向我的应用程序文件夹,例如在Windows上的命令行窗口中,我正在使用python。 I installed python in C:\\Python27 and my sample app is in c:\\GoogleApps\\guestbook 我在C:\\ Python27中安装了python,而我的示例应用程序在c:\\ GoogleApps \\ guestbook中

C:\\Python27>dev_appserver.py c:\\GoogleApps\\guestbook C:\\ Python27> dev_appserver.py c:\\ GoogleApps \\ guestbook

and then I can start my app in the Google App Engine Launcher and hit localhost 8080 然后我可以在Google App Engine启动器中启动我的应用,然后点击localhost 8080

How about specifying --host argument? 如何指定--host参数? You can find it at the bottom of following doc. 您可以在以下文档的底部找到它。

https://developers.google.com/appengine/docs/python/tools/devserver https://developers.google.com/appengine/docs/python/tools/devserver

This might be a little late. 这可能会晚一点。 But still someone might find it useful. 但是仍然有人会觉得它有用。

When ever you go and try changing the port number from 8080 to something else, it will not get updated. 每当您尝试将端口号从8080更改为其他名称时,它都不会更新。 So the best option is: 因此最好的选择是:

  1. Go to your user directory: eg: C:\\Username 转到您的用户目录:例如:C:\\ Username
  2. There will be a Google folder. 将有一个Google文件夹。 Go inside 进去
  3. Open the file google_appengine_projects.ini 打开文件google_appengine_projects.ini
  4. Change your port number from 8080 to whatever you like 8081 将端口号从8080更改为您喜欢的8081
  5. Save it and close the file. 保存并关闭文件。
  6. Launch the GAE Launcher again and you will find the changes reflected and the app runs without issues. 再次启动GAE启动器,您将发现已反映的更改并且该应用程序运行没有问题。

7: Access the application using: http://localhost:NewPort/ 7:使用以下程序访问应用程序: http:// localhost:NewPort /

This can be used to change ports both run port and admin port for your individual projects running locally. 这可用于更改本地运行的单个项目的运行端口和管理端口。 Hope this helps! 希望这可以帮助!

The 8080 portion of your url is a port number. 网址的8080部分是端口号。 Firefox disables visiting url's of other ports by default. Firefox默认禁用其他端口的访问URL。 You have to enable them by doing the following: http://blog.christoffer.me/post/2012-02-20-how-to-remove-firefoxs-this-address-is-restricted/ 您必须通过执行以下操作启用它们: http : //blog.christoffer.me/post/2012-02-20-how-to-remove-firefoxs-this-address-is-restricted/

Paraphrasing that website: 解释该网站:

  1. Open firefox and visit about:conf 打开Firefox并访问about:conf
  2. In the Filter box, type in network.security.ports.banned.override 在“过滤器”框中,键入network.security.ports.banned.override
  3. If you can't find such a preference, right click to open up the pop-up menu and pick New and then String 如果找不到此类首选项,请右键单击以打开弹出菜单,然后依次选择“新建”和“字符串”
  4. As preference name type network.security.ports.banned.override and 8080 as the value. 作为首选项名称,键入network.security.ports.banned.override,并将8080作为值。
  5. Done! 完成!

It's likely if this continues to not work that your browser is behaving properly (8080 is a fairly standard port). 如果浏览器无法正常运行(8080是相当标准的端口),则可能仍然无法正常工作。 That means that its a problem with the server and we'd have to do some more debugging. 这意味着服务器存在问题,我们必须进行更多调试。

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

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