尝试运行 WEBrick for Rails 应用程序,但不断收到错误:“每个套接字仅使用一次...”
信息:Rails 3.0.9;红宝石 1.8.7; Windows 7
我刚刚在 Rails 环境中从 mysql 切换到 postgresql,当尝试在端口 3000 上运行 Rails 时,我一生都无法解决此错误:
WARN TCPServer 错误:每个套接字地址只有一种用法(协议/网络地址/端口)通常是允许的。 -bind(2)
我正在使用 dropbox 在两台计算机之间来回开发,并且在我的家用计算机上一切正常。但在工作中,这个问题让我抓狂。
我在互联网上研究过这个问题,但我认为没有任何答案适用。显而易见的答案是端口被占用。但我无法识别进程中的任何内容,也无法在命令提示符中使用 netstat 来识别将使用此端口的任何内容。
此链接 http://oldwiki.rubyonrails.org/rails/pages/MysteryProcessHoldsOntoWebrickPort 描述了我的问题确实存在,但没有一个解决方案有效。我尝试使用 -p 选项将端口更改为 3001,但随后出现此错误:
无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“???”上运行并接受端口 5432 上的 TCP/IP 连接?
无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“???”上运行并接受端口 5432 上的 TCP/IP 连接?
如果我尝试运行 rake db:migrate,也会出现同样的消息。
因此,除了我已经提到的方法之外,我不知道如何识别和纠正此错误的原因。
我对编程有点陌生,所以我可能会忽略一些东西。任何帮助将不胜感激。
Info: Rails 3.0.9; Ruby 1.8.7; Windows 7
I just switched from mysql to postgresql in my Rails environment, and I cannot for the life of me get around this error when trying to run rails s on port 3000:
WARN TCPServer Error: Only one usage of each socket address (protocol/network address/port) is normally permitted. - bind(2)
I'm developing back and forth between two computers using dropbox, and everything works just fine on my home computer. But at work, this issue is driving me crazy.
I've researched this question all over the internet, and I don't feel any of the answers have applied. The obvious answer is that the port is occupied. But I can't identify anything in my processes or using netstat in the command prompt that would be using this port.
This link http://oldwiki.rubyonrails.org/rails/pages/MysteryProcessHoldsOntoWebrickPort describes my problem exactly, but none of the solutions have worked. I've tried changing the port to 3001 using the -p option, but then I get this error:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "???" and accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "???" and accepting TCP/IP connections on port 5432?
This same message also appears if I try to run rake db:migrate.
So aside from the methods I've already mentioned, I have no idea how identify and remedy the cause of this error.
I'm somewhat new to programming, so I may be overlooking something. Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚遇到了与您的问题非常相似的版本。
Rake db:migrate 没有迁移,它运行并且没有给出错误或迁移消息。 ,问题似乎是 rake 9.2.2 和 rake 8.7 abbr 之间的差异。如果你运行bundle exec rake db:migrate,它可能会起作用,但在我的情况下不起作用。我运行了 sudo gem uninstall rake 和捆绑包安装。还是没用。我卸载了 pg 8.7 并使用 homebrew 重新安装了 pg 9.1.1,并使用 --freeze 打开了一个新的 RoR 文件,该文件 rake db:migrates ...但我无法在模型中进行验证。验证抛出 500 内部服务器错误 - 字符串无法强制为整数。我之所以提到这一切,是因为我刚刚将计算机迁移到 Mac lion 和 postgresql。换电脑我们俩都是。看来连接 postgresql 是这些错误中的共同点。关于在哪里放置 pg 文件以及如何最好配置有很多不同的意见...我在 5432 顺便说一句,保存,查询,只是不验证
I just had a very similar version of your problem.
Rake db:migrate didn't migrate, it ran and gave no errors or migrating msgs. , the problem seemed to be a discrepancy between rake 9.2.2 and rake 8.7 abbr. If u run bundle exec rake db:migrate , it may work but didn't not in my case. I ran sudo gem uninstall rake and the bundle install. It still didn't work. I uninstalled pg 8.7 and reinstalled pg 9.1.1 using homebrew and opened a new RoR file with --freeze and that file rake db:migrates ... But I can't validate in the model. The Validation throws a 500 internal server error - string can't be coerced to integer. The reason I mention all this is because I have just migrated computer to Mac lion and to postgresql. Changing computers we are both. It seems connecting postgresql is the common thread among these errors. A lot differing opinions about where to put pg files and how best to configure ... I'm on 5432 btw , saves, queries , just don't validate