繁体   English   中英

Rails服务器未在端口3000上启动“ TCPServer错误:权限被拒绝-绑定(2)”

[英]Rails server not starting on Port 3000 “TCPServer Error: Permission denied - bind (2)”

我在Windows 7计算机上安装了Ruby on Rails,MySQL Server 5.6和mysql2 gem。 MySQL Server 5.6在端口3000上运行。我的database.yml文件是:

# MySQL2
#   gem install mysql2
#   Ensure the mysql2 gem is defined in your Gemfile
#   gem 'mysql2'
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: demo1_development
  pool: 5
  username: root
  password: root
  host: 127.0.0.1
  port: 3000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: demo1_test
  pool: 5
  username: root
  password: root
  host: 127.0.0.1
  port: 3000

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: demo1
  pool: 5
  username: root
  password: root
  host: 127.0.0.1
  port: 3000

我使用以下Gemfile运行“捆绑安装”:

source 'http://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use mysql2 as the database for Active Record
gem 'mysql2'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

gem 'devise'

gem 'protected_attributes'

gem 'terminator'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

我可以运行“捆绑安装”,“ rake db:create”和“ rake db:migrate”命令,而不会出现任何问题。 我启动了MySQL服务器,并在命令行中键入了“ rails s”。 结果如下:WARN TCPServer错误:权限被拒绝-绑定(2)退出

我确保在Windows防火墙中打开端口3000,并允许导轨通过防火墙进行通信。

键入“ rails s -p 80”可以工作,并且Web应用程序可以在localhost:80上工作,但是该字段将不起作用,因为MySQL Server无法在端口80上运行。

我想念什么吗? 如何使Rails服务器和Web应用程序正常工作?

看起来您正在尝试在端口3000上运行数据库和Rails Web服务器。

编辑:为澄清起见,您可能应该在3000端口(默认)上运行Rails服务器,并在其他端口上运行mysql。

无论您在哪个端口上运行mysql,都将该端口放在“ port:”下的database.yml设置中。

我认为您应该使用端口3306? 这就是我的连接字符串,看起来很正常。

staging:
 adapter: mysql2
 encoding: utf8
 host: 10.0.0.16
 database: my_database
 port: 3306
 username: my_username
 password: my_password

请注意,Web服务器的端口和数据库是两回事。 我通常在端口3000和3306的mysql上正常运行Web服务器。我认为3306是用于mysql的默认端口。

暂无
暂无

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

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