我尝试启动rails服务器并提出以下问题:
neha@SCS-I82:~/work/code/$ rails s
=> Booting Puma
=> Rails 3.2.22 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/neha/.rvm/gems/ruby-2.2.2@canvas/gems/activerecord-3.2.22/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize': FATAL: no pg_hba.conf entry for host "[local]", user "postgres", database "dev2", SSL off (PG::ConnectionBad)
当我尝试启动postgresql服务时,它会出现以下错误:
neha@SCS-I82:~/work/code/$ sudo service postgresql start
* Starting PostgreSQL 9.3 database server * Error: Port conflict: another instance is already running on /var/run/postgresql with port 5432
[fail]
我的/etc/postgresql/9.3/main/pg_hba.conf文件如下:
# Database administrative login by Unix domain socket
local all postgres md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
还通过将端口5432上的正在运行的进程终止为:
来进行检查neha@SCS-I82:~/work/code/lms(ac-99)$ sudo lsof -t -i:3000
neha@SCS-I82:~/work/code/lms(ac-99)$ sudo lsof -t -i:5432
9981
neha@SCS-I82:~/work/code/lms(ac-99)$ sudo kill -9 9981
neha@SCS-I82:~/work/code/lms(ac-99)$ sudo service postgresql start
* Starting PostgreSQL 9.3 database server * Error: Port conflict: another instance is already running on /var/run/postgresql with port 5432
有人可以建议一些解决方案。
答案 0 :(得分:0)
您的端口3000可能已经分配给另一台服务器 要解决此问题,您可以尝试以下命令
$ lsof -i:3000
{{1}}
$ kill -9 12036
上面的命令在运行rails s之后终止PID