简体   繁体   中英

Django on Vagrant, Postgres both locally and on Heroku, could not connect to server: No such file or directory

I finally got my Django app to deploy on Heroku, using Vagrant and Postgres for both local and production. The localhost is up and running, and I'm in the admin, adding users. But when I run

heroku run python manage.py syncdb

it barfs up this error:

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"?

Same thing happens when I try to access the admin online: http://vast-sierra-7949.herokuapp.com/admin/

I'm new to Heroku, and I've tried just about every getting started tutorial I could find, including

http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/

https://devcenter.heroku.com/articles/django ,

https://github.com/callmephilip/django-heroku-bootstrap , and

https://github.com/jpadilla/django-project-template

This last github link actually allowed me to deploy, before I was just getting an error when I ran

git push heroku master

and that error was: manage.py: error: no such option: --noreload

I know there are several posts with this error, but I've looked through as many as I could find with no luck on resolving the issue.

Thank you in advance,

Anthony

Check out this blog post: http://jamie.ideasasylum.com/2012/09/connecting-navicat-to-postgresql-on-vagrant/

The author talks about how you have to modify pg_hba.conf by adding the following lines to allow a host machine (in this case, you Heroku instance) to connect to a postgres server installed on a guest VM within the host.

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             10.0.2.2/32             md5

I'm not sure if you can access these files on a Heroku instance, but it's a place to start. Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM