I am in no way a code developer. Our code developer quit, and I was just given the project. So I am trying to learn code while fixing what ever issues happen. This is the issue that I am currently facing. I need to add new columns into two different tables, I did three separate Active Record Migrations, following the direction. When I tried to update the schema.rb with
$ rake db:migrate
I got the following.
[pcms -update to 4.4 (master)]$ rake db:migrate
WARNING: Nokogiri was built against LibXML version 2.9.2, but has
dynamically loaded 2.8.0
I, [2017-07-20T08:57:20.436515 #64621] INFO -- : ** [Raven] Raven 0.13.0
configured not to send errors.
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
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?
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
database.yml
development:
adapter: postgresql
database: pcms_development
host: localhost
test:
adapter: postgresql
database: pcms_test
host: localhost
Related
I'm currently trying to setup a Redmine installation for our team. I can't seem to establish a connection to our MSSQL server from within rails.
$ RAILS_ENV=production bundle exec rake db:migrate
rake aborted!
TinyTds::Error: closed connection
/home/admin/.rbenv/versions/2.6.6/bin/bundle:23:in `load'
/home/admin/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I installed sqlcmd to test the connection outside out rails, and I managed to login and create and drop a table as a test. I suspect it's my database.yml. I have to connect to an MS SQL Instance, and the server in running on a different port. Tried to tweak around with the settings a bit, but couldn't get it working.
database.yml
production:
adapter: sqlserver
database: Redmine01
dataserver: server\instance
port: ####
username: user
password: "password"
encoding: utf8mb4
While I've played around with rails a bit before, my rails knowledge is definitely limited and I've never set up a connection to an MS SQL server or used the TinyTds gem, therefore I suspect that I simply didn't configure my environment correctly. Hence my post here. I'd really appreciate if one of you rails experts could take a look at the database config. The information I could find regarding configuring rails to connect to named instance combined with a non-standard SQL port were limited.
As a sidenote, for sqlcmd I used "-S server\instance,####" to establish the connection. Which I've surely tried in the database.yml too, but without any success.
In case anyone stumbles upon this, leaving out the instance does the job.
production:
adapter: sqlserver
database: Redmine01
dataserver: server
port: ####
username: user
password: "password"
When I try to connect server to create database. I am getting this error.
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"localhost", "socket"=>"/var/run/postgresql/.s.PGSQL.5432", "pool"=>5, "min_messages"=>"error", "database"=>"rails_contributors_test"}
-- enable_extension("plpgsql")
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
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?
I tried a lot but didn't get success. Looking for help.
Postgres version I have as
which postgres
=> /usr/local/bin/postgres
postgres --version
=> postgres (PostgreSQL) 9.4.4
Try installing Postgres.app on your Mac OSX.
and start the postgres i.e. click on Open psql.
Then, restart the rails server.
After this, it should fix your issue.
Update (If the above does not work)
To fix the issue, remove the PID file. Find the postgres data directory. On Mac OSX using homebrew it is /usr/local/var/postgres/.
To make sure this is the problem, look at the log file (server.log). On the last lines you will see: FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 347) running in data directory "/usr/local/var/postgres"?
If so, rm postmaster.pid
Restart your server. On Mac OSX, do:
launchctl unload homebrew.mxcl.postgresql.plist
launchctl load -w homebrew.mxcl.postgresql.plist
When I run the command: rake db:migrate RAILS_ENV=production I get the following error:
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "93.188.167.2" and accepting
TCP/IP connections on port 5432?
So I guess my server is not listening on port 5432. So how do I solve this?
I know I have to edit some file so in addition to the instructions on how to actually edit the file (I guess it is the file named postgresql.conf?) please also tell me where I should find it.
My web application is on this directory at the server: /home/admin/www/webstudio
EDIT: I have already tried my best to follow the instructions given here: http://alexbachuk.com/launch-rails-4-application-with-passenger-and-nginx/
Trying to run my Rails 4.0.4 (Ruby 2.1.1) application on CentOS 6.5
Failing when I attempt to migrate:
$ rake db:migrate
rake aborted!
PG::ConnectionBad: FATAL: no pg_hba.conf entry for host "::1", user "my_user", database "my_database_dev", SSL off
I am not sure how to tackle this one. On my mac setup all worked fine without having to touch the pg_hba.conf.
Any lead is welcome.
I have created my_user as follow:
CREATE ROLE my_user WITH CREATEDB SUPERUSER LOGIN;
And allowed my_user to access all database with 'trust' in the pg_hba.conf
my config/database.yml contains
development:
adapter: postgresql
host: localhost
encoding: unicode
database: my_database_dev
pool: 5
username: my_user
password:
template: template0
::1 is localhost in ipv6. Your PostgreSQL config doesn't have a config for v6. Try setting your server to 127.0.0.1 the ipv4 address of localhost.
It looks like rake is for some reason passing a bad host, as I assume ::1 is not the name of your server (it looks more like an IP mask of sorts from the Postgres config). (Edit: ::1 is IPv6 localhost, per Doon's comment below.)
Not sure offhand why the same code would work OK on your Mac, but I assume there's a database.yml involved in your Rails config? You may want to try specifying a host attribute in there (it can point to localhost if your server is local) and see if that helps.
i.e.
host: localhost
You'd also want to include one for the port if Postgres is not on the standard port for your Postgres install (5432 with a default install).
I have installed pg on windows 7 and have an existing ruby on rails application that uses sqlite3 and want to change it to postgresql so I can deploy. I also downloaded pgAdmin but I cant start a server from it but I get the following 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?
So i edited database.yml in my rails application to be
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
and after I bundle and it doesnt give an error so pg is installed i try to rake db:create but I also get the same error as above.
but in my services.msc I cant find postgresql-[version] so I tried to start the postgresql service by running cmd in administrator
C:\Windows\system32>NET START postgresql-x64-9.1
The service name is invalid.
C:\Windows\system32>NET START postgresql
The service name is invalid.
What should I do?
You need to add:
host: localhost
under development