Running into the a similar issue as that mentioned here Postgres could not connect to server
I am trying to run rake db:create on a rails 4.1.4 project. I have tried everything mentioned in the previous post - any other suggestions are welcome.
Furthermore, after reinstalling postgres, I ran the command
brew info postgresql and got this Conflicts with: postgres-xc (though I'm not sure if this is relevant). I'm running postgres 9.3.4
Any help will be greatly appreciated...Thanks!
Update: This is the exact error:
could not connect to server: Socket operation on non-socket
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Things I've tried so far:
brew uninstall postgresql
brew update
brew upgrade
brew install postgresql
followed by the list of commands here http://www.postgresql.org/docs/9.3/static/server-start.html
Finally, using the lunchy gem to start postgres worked - http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/
Finally, using the lunchy gem to start postgres worked -
http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/Thanks
Related
I am trying to deploy a Django application on Google Compute Engine. I'm using a Debian 7 image and want to set up Django with Nginx, Gunicorn, virtualenv, supervisor and PostgreSQL. I have everything running fine on my development machine which is running Ubuntu 14.04 with Django installed and PostgreSQL as the backend.
I'm using the tutorial located at http://datacommunitydc.org/blog/2013/12/a-tutorial-for-deploying-a-django-application-that-uses-numpy-and-scipy-to-google-compute-engine-using-apache2-and-modwsgi/. I'm also using the tutorial located at http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/ as it's specific to virtualenv and PostgreSQL which I'm using on my development machine. I've setup my GCE instance, instaled and updated aptitude. I've installed PostgreSQL however when I attempt to create a database user and a new database for the app I get an error and nothing is created.
Following the tutorial I've run:
$ sudo su - postgres
postgres#django:~$ createuser -P
Enter name of role to add: hello_django
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
When it attempts to create the new user role I receive the following error:
createuser: could not connect to database postgres: 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"?
When I run the shell script ls /etc/init.d it says that postgresql is running, but I still can't add the new role. Can someone tell me what I'm doing wrong?
Regards.
I wasn't able to reproduce the issue on my end, but it appears to be an issue with PostgreSQL and its dependencies. You can try removing all installed PostgreSQL components and dependencies and then reinstalling PostgreSQL:
sudo apt-get remove --purge postgresql-9.1*
sudo apt-get install postgresql-9.1
If it's still unable to connect to the database, the issue might be originating from your $PATH, in which case you'll need to point it to /usr/local/bin/psql.
I have just had the same problem.
This is most likely cause the postgres cluster has not been initialised yet.
And the reason that this didn't install automatically is because you have set up the locale of the box yet. This is something that has to be done on Amazon EC2 instances as well.
You need to run:
sudo apt-get install locales
And then:
sudo dpkg-reconfigure locales
I had to choose which locales I wanted to setup, I chose en_AU UTF-8.
After this I rebooted, then I could run this to initialise the cluster:
sudo pg_createcluster 9.1 main --start
This started the service and created the pg_hba.conf files etc.
I faced a similar problem a while back. It can resolved using a few simple steps:
As postgres user run : initdb --locale en_US.UTF-8 -E UTF8 -D 'var/lib/postgres/data'. Note depending on the distro postgres in the command can be pgsql. You can easily check if the directory exists with an ls command.
systemctl start postgresql (if you have systemd) or just a /etc/init.d/postgresql start should do. These commands must be rub as the superuser.
All this is from the ArchWiki.
I'm trying to follow the steps listed here to get PostGIS working with Postgresql and Django on 0SX 10.8 Mountain Lion. However, when I get to step 6: createdb -U USERNAME -E utf8 geodjango I get an error:
createdb: could not connect to database postgres: 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"?
How can I move forward with the installation process here? Is this the right method? Thanks for your ideas!
I'm trying to follow the Heroku tutorial on deploying Django applications:
Getting Started with Django on Heroku
I'm able to run most of it without problems, but when it comes to synching the postgreSQL database I'm getting the following message:
psycopg2.OperationalError: 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"?
I've tried promoting databases,
seting the HOST to /tmp,
modifying the postgresql.conf,
and many other stuff I found searching around without success
I'm working on MB-Pro, Mac OS 10.7 (Lion), and read in some places that this OS was giving developers some headache when it comes to postgre. Did anyone have this problem on OS 10.7, and had it fixed after updating to 10.8? I'm considering updating in case it solves the problem.
Thank's in advance.
EDIT:
The command I'm trying to run is: heroku run python manage.py syncdb
EDIT:
I forgot to delete the DATABASE definition that was already defined on the file.
I made use of the PostgresApp to help with running Postgres on my Mac and then in a terminal ran;
psql -h localhost
I forgot to delete the DATABASE definition that was already defined on the file. It's working now.
Since upgrading OSX to version 10.7.3, when I attempt to run a Django "syncdb" command, I receive the following psycopg2 error from Postgresql 8.4.2:
psycopg2.OperationalError: 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"?
I'm able to open psql without incident, but when I attempt to run "pg_ctl status", I receive this error as well:
pg_ctl: could not open PID file "/Library/PostgreSQL/8.4/data/postmaster.pid": Permission denied
Is there a correlation?
I had the same problem too: updated osx to 10.7.3 and after I restarted the postgres server I got the same issue when I tried to run $ ./manage.py dbshell that goes through psycopg2, but didn't have problem connecting to postgres using psql.
To me the problem appears to be related just to "connections on Unix domain socket", because psycopg2 uses the newly 10.7.3 osx updated postgres library.
I tried to reinstall psycopg2, but nothing was changed.
So, I changed the HOST value on the databases section of my django settings.py, and instead of having an empty string I put 'localhost'.
and it works perfectly!
Eelke 's problem was the same as mine.
The quickest fix for this would be to add
export PGHOST=/tmp
an environment variable in your .bashrc/.zshrc/etc
file (depending on which you use).
The best fix would be to set the specific path in your apps config file.
Did a bit of testing on my Mac and I noticed that there are two versions on my system for several commands. One version is in /usr/bin the other is in /Library/PostgreSQL/9.0/bin. The version in /usr/bin is expecting /var/pgsql_socket/.s.PGSQL.5432, the right version for my install expects /tmp/.s.PGSQL.5432
The version in /usr/bin is 9.0.5 and it has been installed by Apple.
Unfortunatly I do not know much about django, but my bet is it is either calling a command in the wrong path or it is loading a library from the wrong location.
You can fix the problem by creating a symlink:
ln -s /tmp/.s.PGSQL.5432 /var/pgsql_socket/
This did the trick for me in the end...
Change the HOST value in the database dictionary in settings.py to this:
'HOST': '/tmp',
Source:
http://jeffammons.net/2011/09/fixing-postgres-on-mac-10-7-tiger-for-django
Reinstalling psycopg2 worked for me
I ran into the same issue just after upgrading to OSX 10.7.3; reinstalling PostgreSQL solved the problem and did not delete my existing data.
I've installed PostgreSQL and PostGIS, and now I'm trying to follow these instructions:
http://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#spatialdb-template
But I keep getting the following error, both in the command prompt and in Cygwin:
C:\Users\Home>createdb -E UTF8 template_postgis
createdb: could not connect to database postgres: 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"?
And I know PostgreSQL is running, because I'm using it right now!
Installing open source applications can sometimes be so frustrating...
I'll be very grateful for your help!
Are you by any chance using cygwin here? Particuarly, is the system picking up createdb from a cygwin binary?
If your server is cygwin, try removing it and replace it with the Windows version.
If your server is the Windows version, but you have createdb from a cygwin install in the PATH, try removing cygwin from your PATH to make sure you pick up the Windows version of createdb.