I am using PostgreSQL 9.1, which I installed using the DMG provided on the Postgres website. So, my Postgres installation is in /Library/Postgres/9.1.
I am pretty sure my Postgres server is running, but when I run rake db:migrate the rake is aborted with this error:
rake aborted!
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Why is "rake" searching /var/... and not using my installation of Postgres?
Can you supply the link from which you actually downloaded Postgres? It seems like your instance of Postgres has a differently-named socket file than Rails expects, so Rails is unable to find it.
One option is to find the socket that does exist on your system and create a symlink to it from the location mentioned in the output. But my suggestion is to delete this instance of Postgres and simply install it again using Homebrew since you seem to be using OSX. Installation using Homebrew is straightforward: brew install postgresql. After completing the installation just follow the steps listed in the command line output to complete the installation.
Also, if you are using the Postgres.app provided by Heroku you may want to check the documentation.
Related
I'm trying to set up DB, so I used this command: rake db:create.
It resulted in this error, I don't know how to debug this as am new to ROR.
Error:
The `rake` executable in the `redis-rack` gem is being loaded, but it's also present in other gems (rake).
If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).
If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names.
The `rake` executable in the `rake` gem is being loaded, but it's also present in other gems (redis-rack).
If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).
If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names.
W, [2021-10-19T15:11:57.605014 #21509] WARN -- Skylight: [SKYLIGHT] [4.1.2] Running Skylight in development mode. No data will be reported until you deploy your app.
(To disable this message for all local apps, run `skylight disable_dev_warning`.)
rake aborted!
PG::ConnectionBad: 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"?
you could try a fresh installation of PostgreSQL like so:
sudo apt-get update
sudo apt-get remove postgresql
sudo apt-get install postgresql
then
sudo service postgresql status
to make sure its online
I'm trying to locally start my rails server
but do I have to start my postgresql db each time I want to rails s?
I'm new to rails so I'm not sure how this works. I remember not having to do such a thing on something I've worked on before..
As mentioned in other answers you have to make sure that Postgres is runnign and serving your database. This is not handled by Rails.
Usually you would configure the Postgres server as an OS background service that starts with your system. Which operating system do you use? In case it's MacOS and you're already using Homebrew, I'd recommend using Hombrew services. You can read more about it here: https://github.com/Homebrew/homebrew-services
Basically you'd tell Homebrew to start postgres with your system, like this: brew services start postgres
You can use system commands to run postgresql server automatically on system boot
sudo systemctl enable postgresql
or
sudo update-rc.d postgresql enable
However it also belongs on how you install postgres
I'm trying to load a Rails 3.2 project on my Macbook and I'm having difficulty. I installed Postgres 9.1.4 via brew. After putting /usr/local/bin in the front of my $PATH, I can now get into Postgres from the command line via psql.
However, in my Rails project, when I run:
rake db:create:all
I get the following error:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.S.PGSQL.5432"?
Well that file indeed does not exist. Yet I can access the database via the command line with psql.
Why is it looking in that area, and what can I do to make it look in the proper place (whatever that is) for Postgres?
This is depressingly common on OS X systems for users of Homebrew and Postgres.app.
What happens is that your Rails 'Pg' gem gets compiled against the old PostgreSQL version Apple pre-installs on some Mac OS X versions, rather than the version you installed yourself. This happens because the PATH has the Apple version of pg_config on it before the version you installed.
Any of these alternatives will work:
Recompile the Pg gem to use the correct libpq by setting your PATH so that the right pg_config is on it before compiling (best option);
Set an explicit socket directory when you connect with host: /tmp, or with psql etc -h /tmp/;
Use TCP/IP: host: localhost, psql -h localhost, etc;
You can find more detail here:
PostgreSQL Mountain Lion socket issue
Check your database.yml file. Probably a bad configuration
I'm using Rails in a development environment. I'm trying to run simple INSERT commands via the command line, but I can't seem to connect to the SQLite database. Other database-related commands are working fine (e.g. rake db:migrate). I'm using the following command:
rails dbconsole
But I'm getting the following error:
Couldn't find database client: sqlite3. Check your $PATH and try again.
I'm still learning Rails and I'm hoping you rails Rails experts out there will be able to spot the issue.
Sqlite3 isn't installed on your computer, go to the sqlite site and install the command line utility according to whichever operating system your using.
Rails and all my gem files + homebrew installs have been working fine up until this point.
I ran
homebrew install postgresql
and was following the prompts pretty much as indicated in this video but it kept giving me error messages saying there is a server already running. I checked
which psql
in the terminal and it reported a
usr/bin
location rather than
usr/local/bin
indicating I was using the postgres that comes with osx not the new homebrew install.
When I attempted to start the database server I recieved an error message saying the server is already running. There is a mention of this error message in the postgres help documentation but no real working solution.
Attempting brew doctor confirmed that i needed to change my PATH in .bash_profile.
I came across this little snippet here on stack overflow for the .bash_profile edit.
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin
I saved the file and managed to get postgres up and running fine but then when I went to start a new rails app.
rails new blog -d postgresql
it says
Rails is not currently installed on this system. To get the latest version,
simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Any attempt to install does not work until i change the bash_profile file back to what it was before.
If I change it back postgres has the same issue again saying there is already a server running.
Also I thought it might be a launch agent or something but I don't think there are any that are set up.
I figure either something is installed in the wrong place or I have to add something to the .bash_profile?
Don't set your $PATH explicitly. You should append or prepend to it instead:
# In your .bash_profile
export PATH="/usr/local/bin:$PATH"
My guess is that you either use RVM or rbenv. If you change your path to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin explicitly then RVM or rbenv won't be in your path.