2016-07-28 61 views
0

我試圖啓動Rails服務器和它給了以下問題:Postgres的PG :: ConnectionBad錯誤到來而開始軌服務器

[email protected]:~/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/[email protected]/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服務公司給予以下錯誤:

[email protected]:~/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上的運行進程來檢查:

[email protected]:~/work/code/lms(ac-99)$ sudo lsof -t -i:3000 
[email protected]:~/work/code/lms(ac-99)$ sudo lsof -t -i:5432 
9981 
[email protected]:~/work/code/lms(ac-99)$ sudo kill -9 9981 
[email protected]:~/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

它可能已將您的端口3000分配給另一臺服務器。
爲解決這個問題,你可以試試下面的命令

$ lsof的-i:3000

when you press enter you will get below output like 

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 
ruby 12036 tps 12u IPv4 331030  0t0 TCP *:3000 (LISTEN) 

$殺死-9 12036

上述命令後運行Rails小號

殺PID
+0

我沒有得到任何lsof -i輸出:3000命令 – Neha

+0

ohhh然後導軌s應該工作! ok ..嘗試使用「$ netstat -tulpn」這個命令。 –

+0

我編輯了我的問題。 – Neha

相關問題