在我的开发机器上,我使用端口10524.所以我这样启动我的服务器:
rails s -p 10524
Run Code Online (Sandbox Code Playgroud)
有没有办法将默认端口更改为10524,所以每次启动服务器时都不必附加端口?
我在" 入门指南"vagrant的最后遇到了一个小问题.我正在开发运行Apache2的CentOS basebox(通过Puppet进行配置).我已使用以下行为Web请求设置端口转发Vagrantfile:
config.vm.forward_port "web", 80, 4567
Run Code Online (Sandbox Code Playgroud)
但是当我向该端口发出请求时,它们会失败.Safari报告的错误是"Safari无法打开页面" http:// localhost:4567 / ",因为服务器意外断开了连接."
我做了一个,vagrant reload并在滚动中看到"[default] - web:80 => 4567(适配器1)",那么我应该在哪里开始解决这个问题?谢谢.
我有一个在localhost:3000上运行的rails应用程序.我希望从同一网络上的另一台计算机访问它.我觉得我以前很轻松地做过这件事,但这给了我一些悲伤.我可以ping通电脑的IP就好了,但是在浏览器中点击ip:3000是行不通的.我也试过发射rails s -b ipaddress,没有运气.
建议?
我试图在windows中连接localhost:3000
rails server在vagrant中运行(ubuntu 14.10)
portforwarding已完成
什么时候,我lynx 127.0.0.1:3000在ubunutu 尝试
,它的工作原理
但是,在Windows中,我无法连接localhost:3000,127.0.0.1:3000
刚刚显示ERR_CONNECTION_REFUSED
在cmd中,我运行的netstat -t结果是:3000 TIME_WAIT
我怎么解决这个问题?
这是我的'Vagrantfile'
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# …Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails vagrant ruby-on-rails-4 ruby-on-rails-4.2
我想将rails服务器绑定到127.0.0.1而不是0.0.0.0,因此当我在咖啡店工作时无法访问它.
是否有配置文件,我可以指定此选项,所以我不必通过命令行开关:
rails server -b 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
?
我已经看到了这个和其他几个问题,但他们的问题与我的不相似.
我已将以下代码添加到config/boot.rb,以在端口8081上运行我的服务器
module Rails
class Server
def default_options
super.merge({Port: 8081})
end
end
end
Run Code Online (Sandbox Code Playgroud)
然后我试着跑rails s,我面对这个erorr:
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:7:in `<module:Rails>': superclass mismatch for class Server (TypeError)
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:6:in `<top (required)>'
Run Code Online (Sandbox Code Playgroud) 我启动了一个 Rails 应用程序并访问http://127.0.0.1:3000它可以工作,但如果我访问http://192.168.0.59:3000它就不行。我的 Mac 的 IP 地址是192.168.0.59
我认为它以前有效。我想使用我的 iPhone 来访问我的 mac 作为同一内部网络中的本地服务器。任何提示?
编辑:是的,这是因为 rails 服务器绑定127.0.0.1所以只有我自己的机器可以评估,所以rails s -b 0.0.0.0. 因为我用霰弹枪所以shotgun -o 0.0.0.0
我试图连接我的应用程序的api使用curl http://192.168.1.11:4000/api/v1/login 但我总是得到错误curl: (7) Failed to connect to 192.168.1.11 port 4000: Connection refused.
而如果我使用localhost,curl http://localhost:4000/api/v1/login它允许连接到服务器.
奇怪的是我可以使用ip地址curl http://192.168.1.11:3000为我的另一个项目没有任何错误.
如何解决这个问题.