Trying to set Django and postgreSQL on Heroku - django

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.

Related

Apache Superset error when installing locally using Docker Compose

I'm trying to install to my Ubuntu 20.04 local machine using docker-compose. When I run sudo docker-compose -f docker-compose-non-dev.yml up, I got several errors and the process keep giving errors and did not end, so I aborted. Can you please tell me what the problem is?
The errors I get during Init Step 1/4 [Starting] -- Applying DB migrations are:
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) >relation "logs" does not exist
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) >relation "ab_permission_view_role" does not exist
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) >relation "report_schedule" does not exist
I had the same same issue on Mac OS. And similar issues have been reported in the GitHub issues page as well, but it was not reproducible by everyone.
There is a possibility that something may have gone wrong in the first run.
Try running docker-compose down -v and then run docker compose up.
If the above fails, try upgrading your docker installation. Installing a new version solved my problem.
I had the same issue (Mac OS Monterey) where I had an instance of docker running Postgres for one of my apps, so when Superset started, it was looking at that instance of Postgres which obviously didn't have the appropriate databases/tables/views/etc.
So just stopping that other instance and restarting the Superset containers fixed the errors and properly started Superset. #embarrassed #oops
I experienced the same issue but these errors were at the end of a long string of cascading errors. I had this error consistently across all runs.
Looking at the first error, it seems like the initialisation script is not waiting for PostgreSQL to be ready and starts transacting right away. If the first transactions fail, many others fail subsequently. In my case the database needed a few more seconds to be ready so, I just added a sleep 60 at the beginning of docker/docker-bootstrap.sh to give time to PostgreSQL to start before other services start working.
I deleted the previously-created docker volumes and ran docker-compose -f docker-compose-non-dev.yml up again and now all works fine.

PostgreSQL psql: could not connect to server: Connection refused

I am making my first Django app and am trying to deploy to Heroku. I am using a postgres database. My app works fine when I run it on localhost. I pushed my project to Heroku and when I attempt to go to the site I get the following error:
"psql: could not connect to server: Connection refused Is the server running on host
host.domain.com and accepting TCP/IP connections on port 5432?"
So I have been searching endlessly to the solution for this problem, and of the few I have found, NONE can explain clearly the steps involved in changing the postgres settings from localhost. Apparently I am supposed to change a setting in a postgres config file that I cannot find any trace of on my computer, and I can't find command line instructions either. Even the postgres docs don't help.
Can anyone help me to solve this?
Since you pushed your project to Heroku, changing files for your local Postgres installation is irrelevant to the problem.
The question is: Does the remote Postgres installation on Heroku allow remote access? And if yes, what are the exact credentials? For starters, I doubt you can use the standard port 5432. And you may need sslmode=require.
Consult Heroku for the actual credentials. This site may help:
https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress

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
Be sure to setup heroku DB settings
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!

Trouble with Django-Kronos

I have a weird problem with Django-Kronos.
I've got it running successfully on my local machine and on our development server. However, on the production server, I can't get kronos to acknowledge my cron.py file. When I run installtasks, it runs but says "0 tasks installed". I've also tried running the tasks manually and kronos tells me the task doesn't exist.
We use git to push everything through to the server, so all the files and the structures are identical between the three locations. I've also checked and the cron.py file exists and has exactly the same content as the working servers.
The only differences between the servers is that the production server is running Postgres (SQlite on the dev server) and it's Ubuntu 12.10, whereas the dev server is 12.01.
Kronos is functioning properly, but it's not picking up our cron.py file for some reason....
Any got any ideas?!
Well, unfortunately, our solution was to scrap Django-Kronos altogether and create a custom management command which we're running from the crontab.
This happens when one of import you are trying to make is not there, your production system might be missing some Python package which is included in your cron.py.

Postgresql socket error on OSX 10.7.3 when running Django's syncdb

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.