I am having some troubles creating my database.
My postgresql is running for sure.
Here's the database.yml:
development:
<<: *default
database: name_of_database
User: username
Password: tototo
I get the message:
Called from /usr/local/bundle/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/usr/local/bundle/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/usr/local/bundle/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
[...]
/usr/local/bundle/bin/rake:17:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"name_of_database", "User"=>"username", "Password"=>"tototo"}
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
[...]
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/usr/local/bundle/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:17:in `load'
/usr/local/bundle/bin/rake:17:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"name_of_database"}
I created the user giving it every rights.
I can connect to postgresql with the client using the IDs.
And I have an other project succeeding to connect to postgres.
Does someone have an idea to fix this?
Thanks.
Your postgres server might not had started try this
$sudo service postgresql restart
Then go to your rails project
$rake db:setup
$rake db:seed
$rake db:migrate
Related
I installed postgres from brew.
I got an error, I tried to delete the postmaster.id
The file seems to be missing.
rm -f data/postmaster.pid
It had no effect.
I tryed
$brew install postgres
$psql --version
psql (PostgreSQL) 14.1
$postgres --version
postgres (PostgreSQL) 14.1
$psql
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: database "t" does not exist
$postgres -D /usr/local/var/postgres
2022-01-28 14:27:14.406 JST [94892] LOG: starting PostgreSQL 14.1 on aarch64-apple-darwin21.1.0, compiled by Apple clang version 13.0.0 (clang-1300.0.29.3), 64-bit
2022-01-28 14:27:14.408 JST [94892] LOG: could not bind IPv6 address "::1": Address already in use
2022-01-28 14:27:14.408 JST [94892] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2022-01-28 14:27:14.408 JST [94892] LOG: could not bind IPv4 address "127.0.0.1": Address already in use
2022-01-28 14:27:14.408 JST [94892] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2022-01-28 14:27:14.408 JST [94892] WARNING: could not create listen socket for "localhost"
2022-01-28 14:27:14.408 JST [94892] FATAL: could not create any TCP/IP sockets
2022-01-28 14:27:14.409 JST [94892] LOG: database system is shut down
$rm /usr/local/var/postgres/postmaster.pid
rm: /usr/local/var/postgres/postmaster.pid: No such file or directory
$sudo lsof -i:5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
postgres 94724 t 7u IPv6 0xe42d991dab624b7 0t0 TCP localhost:postgresql (LISTEN)
postgres 94724 t 8u IPv4 0xe42d991d7856c0f 0t0 TCP localhost:postgresql (LISTEN)
I don't know why you insist in wrecking your PostgreSQL server by removing the PID file. I wish you would stop doing that.
The error message means that you are trying to connect to database t, but that database does not exist. Since you do not explicitly specify a database, the causes could be:
you are operating system user t, so the connection defaults to database t
the environment variable PGDATABASE is set to t
the environment variable PGUSER is set to t, and the connection defaults to the same database name as the user name
In any event, the solution is to pick an existing database and use
psql -d dbname
I run Windows and I am trying to install postgres, but I can't get it to work. During installation, I get the error:
Failed to load sql modules into the database cluster
When I try to access the server in pgadmin or via SQL Shell, I get the error:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?"
I have found a log in the data-folder saying:
2021-04-08 14:53:44.315 CEST [11088] LOG: starting PostgreSQL 13.2, compiled by Visual C++ build 1914, 64-bit
2021-04-08 14:53:44.321 CEST [11088] LOG: could not listen on IPv6 address "::": Permission denied
2021-04-08 14:53:44.326 CEST [11088] LOG: could not listen on IPv4 address "0.0.0.0": Permission denied
2021-04-08 14:53:44.327 CEST [11088] WARNING: could not create listen socket for "*"
2021-04-08 14:53:44.328 CEST [11088] FATAL: could not create any TCP/IP sockets
2021-04-08 14:53:44.331 CEST [11088] LOG: database system is shut down
Can someone please help me?
I had the same issue and followed different tips and tricks available on the internet but nothing worked.
I fixed that issue by following these steps:
First disable antivirus for an hour
Create a folder in either C drive or D drive and give full permission to User
Then again install a fresh application. If you have already installed then uninstall that and install from starting.
Make sure to choose that folder only at the time of installation
I'm running into an exception with Sinatra 2.0.0 beta 2 with Rails 5 deploying to the Amazon Linux AMI v 2.1.6. I've posted the issue in the Sinatra Github repro but it's been suggested I post it here.
Edit: I ran into this using Elastic Beanstalk but as #neal reports, this also happens with Capistrano deploying to EC2.
Steps to reproduce the issue follow:
Make a new Rails 5 application in a clean directory
$ gem install rails
$ rails --version
(confirm Rails 5.0.0.1)
$ rails new test-app
Add this line to the gemfile:
gem 'sinatra', '2.0.0.beta2'
Create a new Elastic Beanstalk Web environment of type “64bit Amazon Linux 2016.03 v2.1.6 running Ruby 2.3 (Puma)”, Web server. Use all defaults except change the instance size to t2.small (anything smaller doesn’t have enough memory to deploy)
Add two new environment variables to the Elastic Beanstalk environment using the Web console
SECRET_KEY_BASE = (set a value for this)
RAILS_ENV = production
Deploy the application to this new environment, for example with the eb command line tools.
Deploy it again
Tail the logs through the Elastic Beanstalk console
RESULT:
-------------------------------------
/var/log/puma/puma.log
-------------------------------------
=== puma startup: 2016-08-26 02:39:12 +0000 ===
=== puma startup: 2016-08-26 02:39:12 +0000 ===
[15926] - Worker 0 (pid: 15929) booted, phase: 0
[15926] - Gracefully shutting down workers...
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:11:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:11:in `block in <class:Application>'
from (eval):1:in `run?'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:26:in `block in <module:Sinatra>'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:120:in `fork'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:120:in `block in spawn_workers'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:116:in `times'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:116:in `spawn_workers'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:426:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/launcher.rb:172:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cli.rb:74:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/bin/puma:10:in `<top (required)>'
from /opt/rubies/ruby-2.3.1/bin/puma:23:in `load'
from /opt/rubies/ruby-2.3.1/bin/puma:23:in `<top (required)>'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:63:in `load'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:63:in `kernel_load'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:24:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli.rb:304:in `exec'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli.rb:11:in `start'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/exe/bundle:27:in `block in <top (required)>'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/exe/bundle:19:in `<top (required)>'
from /opt/rubies/ruby-2.3.1/bin/bundle:23:in `load'
from /opt/rubies/ruby-2.3.1/bin/bundle:23:in `<main>'
[15926] === puma shutdown: 2016-08-26 02:41:17 +0000 ===
[15926] - Goodbye!
=== puma startup: 2016-08-26 02:41:20 +0000 ===
=== puma startup: 2016-08-26 02:41:20 +0000 ===
[16296] - Worker 0 (pid: 16299) booted, phase: 0
This isn't just an elastic bean stalk issue, I can confirm it also happens when deploying a rails 5 app using capistrano / EC2 Ubuntu / nginx
My instance has a maximum number of connections of 16. As soon as I realized that I had 19 connections, I hurried to kill one, which turns out to open a standard connection with the same priority and limitations.
I have now reached the absolute maximum number of connection, which is 20, and cannot even do a pg:ps or a pg:killall.
How can I kill all connections, or do anything to lower the number of connections now? The query which seems to be blocking is extremely long (seems like a select * from a table which has 410k entries).
$ heroku pg:info -a XYZ
=== HEROKU_POSTGRESQL_COBALT_URL (DATABASE_URL)
Plan: Basic
Status: Available
Connections: 19
PG Version: 9.1.11
Created: 2013-03-12 15:11 UTC
Data Size: 7.16 GB
Tables: 103
Fork/Follow: Unsupported
Rollback: Unsupported
$ heroku pg:ps -a XYZ
procpid | source | running_for | waiting | (...)
$ heroku pg:kill 12593 -a XYZ
pg_cancel_backend
-------------------
t
(1 row)
$ heroku pg:ps -a XYZ
psql: FATAL: too many connections for role "abc"
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: undefined method `[]' for nil:NilClass (NoMethodError)
Backtrace: /home/chris/.heroku/client/lib/heroku/command/pg.rb:442:in `version'
/home/chris/.heroku/client/lib/heroku/command/pg.rb:447:in `nine_two?'
/home/chris/.heroku/client/lib/heroku/command/pg.rb:451:in `pid_column'
/home/chris/.heroku/client/lib/heroku/command/pg.rb:226:in `ps'
/home/chris/.heroku/client/lib/heroku/command.rb:218:in `run'
/home/chris/.heroku/client/lib/heroku/cli.rb:37:in `start'
/usr/local/heroku/bin/heroku:24:in `<main>'
Command: heroku pg:ps -a XYZ
Version: heroku-toolbelt/3.9.6 (x86_64-linux) ruby/2.0.0
$ heroku pg:killall -a XYZ
psql: FATAL: too many connections for role "abc"
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: undefined method `[]' for nil:NilClass (NoMethodError)
Backtrace: /home/chris/.heroku/client/lib/heroku/command/pg.rb:442:in `version'
/home/chris/.heroku/client/lib/heroku/command/pg.rb:447:in `nine_two?'
/home/chris/.heroku/client/lib/heroku/command/pg.rb:451:in `pid_column'
/home/chris/.heroku/client/lib/heroku/command/pg.rb:272:in `killall'
/home/chris/.heroku/client/lib/heroku/command.rb:218:in `run'
/home/chris/.heroku/client/lib/heroku/cli.rb:37:in `start'
/usr/local/heroku/bin/heroku:24:in `<main>'
Command: heroku pg:killall -a XYZ
Version: heroku-toolbelt/3.9.6 (x86_64-linux) ruby/2.0.0
$ heroku pg:info -a XYZ
=== HEROKU_POSTGRESQL_COBALT_URL (DATABASE_URL)
Plan: Basic
Status: Available
Connections: 20
PG Version: 9.1.11
Created: 2013-03-12 15:11 UTC
Data Size: 8.24 GB
Tables: 103
Fork/Follow: Unsupported
Rollback: Unsupported
I grabbed the following toolbelt add-on which worked perfectly.
https://github.com/heroku/heroku-pg-extras#usage
My solution was to promote another DB and assign the original again
heroku addons:add heroku-postgresql:hobby-basic
#Attached as NEW_DATABASE_URL
heroku pg:promote NEW_DATABASE_URL
heroku pg:promote ORIGINAL_DATABASE_URL
Then verify your db connections
I encountered troubles when trying to connect to postgresql database within Zend framework application. In my application.ini I use
resources.db.adapter = PDO_PGSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = testtest
resources.db.params.dbname = testdb
But when I run the application, I got an error message
Message: SQLSTATE[08006] [7] could not create socket: Address family not supported by protocol.
Could you please tell me what can be wrong?
Zend version 1.12.3., PostgreSQL version 9.0.7, PHP version 5.3.5.
Thanks, Marek .
localhost on your machine is (most likely) resolving to the IPv6 address of localhost (::1), but since the protocol/module used does not support IPv6 connections, your connection fails.
You could either;
Use 127.0.0.1 as a host instead, that will force a connection to the IPv4 localhost.
Remove the host line completely, that will force a connection via UNIX sockets.
I had similar problem:
PDOException: SQLSTATE[08006] [7] could not connect to server:
Connection refused Is the server running on host "localhost"
(127.0.0.1) and accepting TCP/IP connections on port 5432? in
lock_may_be_available() (line of /app/ctr/ctr
web/drupal/includes/lock.inc).
The problem was caused because of a full disk. and PostgreSQL DB blocked/froze.
Making some free space and restarting of PostgreSQL DB resolved my problem.