GitLab 7.4.3 HTTP-Code 500: Could not connect to Server - ruby-on-rails

I installed GitLab with the omnibus installer and now i have the problem that i become a http error 500 when i try to go on the website. I use nginx as webserver and gitlab is reachable under the port 8000.
This is the error message i have in the production.log:
==> ./gitlab/gitlab-rails/production.log <==
Started GET "/" for 212.227.35.68 at 2014-11-14 10:15:07 -0600
PG::Error (could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
):
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `initialize'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `new'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `connect'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/opt/gitlab/embedded/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/opt/gitlab/embedded/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
activerecord (4.1.1) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.1.1) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.1.1) lib/active_record/query_cache.rb:51:inn`restore_query_cache_settings'
activerecord (4.1.1) lib/active_record/query_cache.rb:43:in `rescue in call'
activerecord (4.1.1) lib/active_record/query_cache.rb:32:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
railties (4.1.1) lib/rails/railtie.rb:194:in `public_send'
railties (4.1.1) lib/rails/railtie.rb:194:in `method_missing'
rack (1.5.2) lib/rack/builder.rb:138:in `call'
rack (1.5.2) lib/rack/urlmap.rb:65:in `block in call'
rack (1.5.2) lib/rack/urlmap.rb:50:in `each'
rack (1.5.2) lib/rack/urlmap.rb:50:in `call'
unicorn (4.6.3) lib/unicorn/http_server.rb:552:in `process_client'
unicorn-worker-killer (0.4.2) lib/unicorn/worker_killer.rb:51:in `process_client'
unicorn (4.6.3) lib/unicorn/http_server.rb:632:in `worker_loop'
unicorn (4.6.3) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
unicorn (4.6.3) lib/unicorn/http_server.rb:142:in `start'
unicorn (4.6.3) bin/unicorn:126:in `<top (required)>'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/unicorn:23:in `load'
/opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/unicorn:23:in `<main>'
Here my nginx default page configuration:
server {
listen 8000; ## listen for ipv4; this line is default and implied
listen [::]:8000 default_server ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
}
And the gitlab.rb config file:
# Change the external_url to the address your users will type in their browser
external_url 'http://gitlab.domain.com:8000'
# External URL to reach the GitLab CI Coordinator at
ci_external_url 'http://ci.domain.com:8000'
Everything runs on an Debian 7 server and i installed the actuall gitlab version 7.4.3.
After the installation process i modified the gitlab.rb an startet the reconfigure for gitlab
gitlab-ctl reconfigure. After that i started gitlab with gitlab-ctl start.
Edit:
I have tested to open the website for the CI but there are the same error messages.

I have found a solution for this problem but i created a new problem.
First the solution:
The gitlab installation search for the file under /tmp/.s.PGSQL.5432 and i can find the file under /var/run/postgresql/.s.PGSQL.5432 so i created a link with ln -s /var/run/postgresql/.s.PGSQL.5432 /tmp/.s.PGSQL.5432 and now the error doesn't appear anymore.
The next error says that there are no gitlab user for postgresql but i have created one. Look this post:
Gitlab 7.4.3: PG::Error Peer-Authentifizierung fehlgeschlagen

I had the same problem, found a more drastic approach that worked for me:
sudo gitlab-ctl stop
mv /var/opt/gitlab/postgresql /var/opt/gitlab/postgresql.bak
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
Since the PostgreSQL files are 'corrupt' in some way, Gitlab just regenerates them. All my old data (settings, users, repositories and comments) is still there.

The problem in you db server. Rails app tries to access if via Unix domain socket "/tmp/.s.PGSQL.5432"?
Show you PG settings and database.yml
Probably PG listens only TCP sockets, but not UNIX. You should configure it.

Related

PG ConnectionBad Could not connect to server

Full error is:
PG::ConnectionBad (could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
):
pg (1.2.3) lib/pg.rb:58:in `initialize'
pg (1.2.3) lib/pg.rb:58:in `new'
pg (1.2.3) lib/pg.rb:58:in `connect'
activerecord (6.0.2.2) lib/active_record/connection_adapters/postgresql_adapter.rb:46:in `postgresql_connection'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:889:in `new_connection'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:933:in `checkout_new_connection'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:912:in `try_to_checkout_new_connection'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:873:in `acquire_connection'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:595:in `checkout'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:439:in `connection'
activerecord (6.0.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:1121:in `retrieve_connection'
activerecord (6.0.2.2) lib/active_record/connection_handling.rb:238:in `retrieve_connection'
activerecord (6.0.2.2) lib/active_record/connection_handling.rb:206:in `connection'
activerecord (6.0.2.2) lib/active_record/migration.rb:562:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.2.2) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.2.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.2.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.2.2) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.2.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.2.2) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.2.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.2) lib/rack/method_override.rb:24:in `call'
rack (2.2.2) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.2.2) lib/rails/engine.rb:526:in `call'
puma (3.12.4) lib/puma/configuration.rb:227:in `call'
puma (3.12.4) lib/puma/server.rb:675:in `handle_request'
puma (3.12.4) lib/puma/server.rb:476:in `process_client'
puma (3.12.4) lib/puma/server.rb:334:in `block in run'
puma (3.12.4) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
I tried rm the postmaster.pid but then it prints no such file. I also tried restarting postgresql multiple times but it keeps printing the same exact error.
I know that there is not much thats all the info I have regarding the problem
I will send you some steps that help me with this issue:
CHECKING POSTGRES STATUS AND RUNNING PORT (if it is on 5432):
Ubuntu/Linux Distros (Terminal):
$ pg_lsclusters
or
$ systemctl status postgresql.service
or
$ service postgresql status
Windows:
Ctrl+R type services.msc
You should find the postgres status and the port which it is running
STARTING POSTGRES SERVICE:
Ubuntu/Linux Distros (Terminal):
$ systemctl start postgresql.service
or
$ sudo service postgresql start
Windows
Ctrl + R type services.msc find your postgres service and just start it.
CHECKING AND CREATING USER ROLE ON POSTGRES
First connect to the database:
$ sudo su postgres
$ psql
Then check if your role is created with the command:
$ \du
If it's not created yet you can create by using:
$ CREATE role name_of_your_role_here WITH createdb login password 'your_password_here';
After that you could try again to connect to the database:
don't forget to use
rake db:create
rake db:migrate
and configure database.yml file on your application
Change Client Authentication Method on PG_HBA.CONF
You can see more details of it right here: pg_hba.conf
You would probably use md5 password method or no auth at all for tests purpose
To do that, you could change the METHOD column of your localhost from peer(default) to md5
You can find this file on:
LINUX DISTROS:
cd /etc/postgresql/your postgres version here/main/pg_hba.conf
WINDOWS:
C:/Porgram Files/PostgresSQL/your postgres version
her/data/pg_hba.conf
Option method with simple user/password:
TYPE DATABASE USER ADDRESS METHOD
IPv4 local connections:
host all all 127.0.0.1/32 md5 <= CHANGE HERE
Option method with no Password:
TYPE DATABASE USER ADDRESS METHOD
IPv4 local connections:
host all all 127.0.0.1/32 trust <= CHANGE HERE
Windows 10
In my case, PostgreSQL Server wasn't running so I had to start it as follows:
Open the Run app
Type services.msc
Find postgresql-x64-13 - PostgreSQL Server 13 (Its description is: Provides relational database storage.)
Right click, and select Start

Rails / Postgres connection issue (psql and pg working fine)

My rails app connects to the database on my development machine, and in production just fine. I've cloned the project to a coworker's machine, and recreated the database locally from a pgdump. The same process works fine on my machine. But on his,
psql at the command line is having no trouble:
$ psql ROL2
psql (9.5.2)
Type "help" for help.
ROL2=#
And to test the pg gem (pg-0.18.4), I've written a simple ruby script to output our users' names:
#!/usr/bin/env ruby
require 'pg'
conn = PG.connect( dbname: 'ROL2' )
conn.exec( "SELECT * FROM users" ) do |result|
result.each do |row|
puts "#{row['first_name']} #{row['last_name']}"
end
end
No problem; works fine. But when I try connecting via the rails console or a task in the app:
$ rails db
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Here's the database.yml:
# LOCAL POSTGRES
development:
adapter: postgresql
encoding: utf8
host: localhost
port: 5432
database: ROL2
pool: 5
Ditto when I try to connect with a client (Postico). I've tried with both the postgres user and his username / password.
ROL2=# \du
List of roles
Role name | Attributes | Member of
-------------+------------------------------------------------------------+-----------
joeschmo | Superuser, Create role, Create DB | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Why might Rails have trouble connecting to the database, even though psql and the pg gem are working fine?
Added: the error as it appears in the Rails development logs:
PG::ConnectionBad (server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
):
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `initialize'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `new'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/Users/mac_osx_username/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `new'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
activerecord (4.2.4) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/Users/mac_osx_username/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/Users/mac_osx_username/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
activerecord (4.2.4) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.2.4) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.2.4) lib/active_record/migration.rb:383:in `connection'
activerecord (4.2.4) lib/active_record/migration.rb:370:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.4) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
Since the database.yml includes host and port, Rails is probably trying to connect to the TCP socket, whereas your connections via psql and pg (since they don't specify host or port) are using the UNIX socket. PostgreSQL comes configured out of the box to not listen to the TCP socket, so look at the postgresql.conf and ensure it has listen_addresses uncommented. If it doesn't, you can try either taking host and port out of the database.yml or modifying the config to enable TCP connections and restarting PostgreSQL.

Rails server not working on Cloud9

A Rails newbie here. I'm having problem with cloned Shopify app to develop on Cloud9. I need to run on rails s -b $IP -p $PORT to see a preview, but i can't access to first page at all. it showed 500 server error (full msg: A static HTML page can contain a simple dependency free script to set the top bar to a 500 server error. This page can be found in 'public/500.html'.)
I tried to find solution here and here. Both of them suggest to modify pg_hba.conf But I check my file and it's the same as them so I didn't modify it at all.
I did try to change my database.yml from host: localhost -> host: /var/run/postgresql but I got another error msg. It seems not a solution.
Could you help me?
Here's my log
icys#c_app:~/workspace (master) $ rails s -b $IP -p $PORT
=> Booting Thin
=> Rails 4.2.0 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on 0.0.0.0:8080, CTRL+C to stop
Started GET "/" for 171.96.244.172 at 2015-09-01 13:44:42 +0000
PG::ConnectionBad (fe_sendauth: no password supplied
):
activerecord (4.2.0) lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
activerecord (4.2.0) lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
activerecord (4.2.0) lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
activerecord (4.2.0) lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
activerecord (4.2.0) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
activerecord (4.2.0) lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
activerecord (4.2.0) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.2.0) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.2.0) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
activerecord (4.2.0) lib/active_record/query_cache.rb:43:in `rescue in call'
activerecord (4.2.0) lib/active_record/query_cache.rb:31:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.1) lib/rack/content_length.rb:15:in `call'
thin (1.6.3) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.3) lib/thin/connection.rb:84:in `catch'
thin (1.6.3) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.3) lib/thin/connection.rb:53:in `process'
thin (1.6.3) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.7) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.7) lib/eventmachine.rb:187:in `run'
thin (1.6.3) lib/thin/backends/base.rb:73:in `start'
thin (1.6.3) lib/thin/server.rb:162:in `start'
rack (1.6.1) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.1) lib/rack/server.rb:286:in `start'
railties (4.2.0) lib/rails/commands/server.rb:80:in `start'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `tap'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.0) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Here's my database.yml
development:
adapter: postgresql
encoding: unicode
database: development
pool: 5
host: localhost
username: action
password:
Here's my pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres peer
# 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

Postgres won't connect to server in Ruby on Rails app using c9.io

A few days ago, I was able to successfully install Postgresql and create/migrate my databases over from SQLite (in preparation for deploying my Rails 4 app)...or so I thought.
I restarted my server, but when I try to access my app, I get this error:
PG::ConnectionBad
could not connect to server: Connection refused
Is the server running locally and accepting connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"?
I've seen several similar answered questions on SO, but they all involve Macs. Since i'm using the Cloud 9 IDE instead, I thought there might be differences (for instance, the mentions of localhost are probably not relevant, because that's not how I access the app currently on c9.io.)
According to the answers on the other questions, I tried this in my terminal:
sudo ps auxw | grep post
which gave me:
ubuntu 2527 0.0 0.0 10552 888 pts/5 S+ 15:21 0:00 grep --color=auto post
then I tried:
sudo find / -name .s.PGSQL.5432 -ls
and I got:
5286 0 lrwxrwxrwx 1 root root 26 May 11 15:13 /var/pgsql_socket/.s.PGSQL.5432 -> /private/tmp/.s.PGSQL.5432
5183 0 srwxrwxrwx 1 postgres postgres 0 May 10 22:18 /run/postgresql/.s.PGSQL.5432
yamilethmedina#wheels_registration:~/workspace (master|MERGING) $ psql
psql: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Here is the full trace of my server:
Started GET "/" for 12.43.117.2 at 2015-05-11 16:35:48 +0000
PG::ConnectionBad (could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
):
activerecord (4.1.6) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
activerecord (4.1.6) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
activerecord (4.1.6) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
activerecord (4.1.6) lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
activerecord (4.1.6) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
activerecord (4.1.6) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
activerecord (4.1.6) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.1.6) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.1.6) lib/active_record/migration.rb:388:in `check_pending!'
activerecord (4.1.6) lib/active_record/migration.rb:377:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.6) lib/rails/engine.rb:514:in `call'
railties (4.1.6) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Rendered /usr/local/rvm/gems/ruby-2.1.5#rails4/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.1ms)
Rendered /usr/local/rvm/gems/ruby-2.1.5#rails4/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.8ms)
Rendered /usr/local/rvm/gems/ruby-2.1.5#rails4/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (2.9ms)
Rendered /usr/local/rvm/gems/ruby-2.1.5#rails4/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (45.7ms)
My entire github repo just in case:
https://github.com/yamilethmedina/wheels_registration.git
It doesn't look like postgresql is running. Perhaps it is not set to auto start. One reason for this can be if postgresql wasn't cleanly shutdown on the last run, and leaves a pid file laying around.
Try
sudo service postgresql start
and see if it comes back, and just make sure that you shut the vm down (so the stop scripts can run) as opposed to just powering it off.

Getting Puma Postgres Server to Work in Development to Cooperate with Heroku, or does going back to Sqlite make sense?

I got using puma instead of rails s to work fine for awhile, but then while developing and making code changes and refreshing at some point the refresh wasn't working, delaying for a long time. I assumed it had crashed or something, so I killed the puma server, but then it said 'gracefully shutting down' for several minutes so I killed the terminal window. Then, in a new window when I tried to use puma it said the host was already taken, so the process was still running. Unable to find where it was, I restarted my computer. Upon restart, I now get the error An unhandled lowlevel error occured. The application logs may have details. or PG::ConnectionBad fe_sendauth: no password supplied, depending on whether I run puma or RAILS_ENV=development puma.
Neither of these responses seem to make sense, and this error I see others having on rake db:migrate. So I tried migrating the database and got the same error PG::ConnectionBad: fe_sendauth: no password supplied
And in the logs when trying to run the server: Rack app error: #<RuntimeError: Missingsecret_key_basefor 'production' environment, set this value inconfig/secrets.yml>
Now this makes the least sense to me, as why is puma running production environment by default and requiring a special command to run in development?
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Is dependent on Heroku to pass the secret_key_base is my assumption, so it doesn't work for development. But then even RAILS_ENV=development puma throws
PG::ConnectionBad
fe_sendauth: no password supplied
And a trace that doesn't appear to help me:
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/Users/lasernite/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/Users/lasernite/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
activerecord (4.1.7) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.1.7) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.1.7) lib/active_record/migration.rb:388:in `check_pending!'
activerecord (4.1.7) lib/active_record/migration.rb:377:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.7) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.7) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.7) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.7) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
rack-timeout (0.2.0) lib/rack/timeout.rb:108:in `call'
railties (4.1.7) lib/rails/engine.rb:514:in `call'
railties (4.1.7) lib/rails/application.rb:144:in `call'
puma (2.11.0) lib/puma/configuration.rb:82:in `call'
puma (2.11.0) lib/puma/server.rb:507:in `handle_request'
puma (2.11.0) lib/puma/server.rb:375:in `process_client'
puma (2.11.0) lib/puma/server.rb:262:in `block in run'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `call'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `block in spawn_thread'
I'm stuck on where to try and resolve this error.
Please give any insight you can. Thanks!
Is your "config/secrets.yml" file listed in .gitignore? Heroku needs that file. Remove or comment it out from .gitignore. I had the same problem and that was my issue.
Also, see this post for the same answer:
How to solve error "Missing `secret_key_base` for 'production' environment" (Rails 4.1)
Good luck!

Resources