Ruby-on-rails 无法分配请求的地址 - bind(2) (Errno::EADDRNOTAVAIL)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13853936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot assign requested address - bind(2) (Errno::EADDRNOTAVAIL)
提问by Mahardhika
I am using rail for teambox at centos 6.3 server, actually this is just a trial and error before applying it live.
我在 centos 6.3 服务器上为 teambox 使用 rail,实际上这只是在应用它之前的反复试验。
- I'm using 2 virtual box that running on same centos version and exact copy, VM2 is only run mysql that will be remote from VM1
- I have tried mysql connection #nc and it's connected
- VM1 (192.168.7.201) & VM2 (192.168.7.202 running MYSQL)
- I have bind-address on remote machine (VM2) in my.cnf with bind-address=192.168.7.202
- here's my database.yml
- 我正在使用 2 个在相同 centos 版本和精确副本上运行的虚拟机,VM2 仅运行将远离 VM1 的 mysql
- 我已经尝试过 mysql 连接 #nc 并且它已连接
- VM1 (192.168.7.201) & VM2 (192.168.7.202 运行 MYSQL)
- 我在 my.cnf 中的远程机器(VM2)上有绑定地址,bind-address=192.168.7.202
- 这是我的 database.yml
development:
adapter: mysql
host: 192.168.7.202
port: 3306
username: teambox
password: pass
database: teambox
开发:
适配器:mysql
主机:192.168.7.202
端口:3306
用户名:teambox
密码:pass
数据库:teambox
and I am trying to run with #rails server -e development -b 192.168.7.202and giving this error
我正在尝试使用 # 运行rails server -e development -b 192.168.7.202并给出此错误
Exiting
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/tcphack.rb:12:in `initialize_without_backlog': Cannot assign requested address - bind(2) (Errno::EADDRNOTAVAIL)
please help me out
请帮帮我
回答by Bill Panagiotopoulos
try this
尝试这个
rails server -e development -b 0.0.0.0 -p 3000
0.0.0.0 means it listens on all IPv4 addresses on the local machine
0.0.0.0 表示它侦听本地机器上的所有 IPv4 地址
回答by Surinder Dhillon
Rails 5.0.0.1 server not working without IPv6. You need to enable IPv6 from /etc/sysctl.conf file(IPv6 is enabled by default). Remove or comment these lines if you have any.
Rails 5.0.0.1 服务器在没有 IPv6 的情况下无法工作。您需要从 /etc/sysctl.conf 文件中启用 IPv6(默认启用 IPv6)。如果有的话,删除或注释这些行。
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Reboot the server to enable IPv6.
重新启动服务器以启用 IPv6。
try
尝试
rails server
导轨服务器
回答by VenkatK
Try as following:
尝试如下:
development:
adapter: mysql
host: 127.0.0.1
port: 3306
username: teambox
password: pass
database: teambox
(or)
(或者)
development:
adapter: mysql
host: localhost
port: 3306
username: teambox
password: pass
database: teambox
I think any of the above will work.
我认为以上任何一种都会起作用。
回答by Salil
This means the server is already running on that port
这意味着服务器已经在该端口上运行
try
尝试
rails server -e development -p 3001 -b 192.168.7.202
回答by vijikumar
The error is coming becuase 3000 port is already in use. And the command is trying to run in the same port. so change the port and run. add this also -p 3002
由于 3000 端口已在使用中,因此出现错误。并且该命令正试图在同一个端口中运行。所以更改端口并运行。也添加这个 -p 3002

