Forums

Error 500, I can't connect my database

Error 500, I can't connect my database

Hi there, I struggled deploying my site, I have some bugs like this:

  1. psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 011Is the server running on that host and accepting TCP/IP connections?
  2. ValueError: Missing staticfiles manifest entry for 'assets/images/favicon.ico'

I think the worst bug is the first one, because I can't connect my database, I don't get it why, I just replaced the info from my "databases" section to my settings.py file; that is the only database I'm working on.

DATABASES ={ 'default': { 'ENGINE':'django.db.backends.postgresql', 'NAME': I replace here, 'USER': I replace here, 'PASSWORD':' I replace here', 'HOST': I replace here, 'PORT': I replace here } }

Could you tell me how I can fix it?

The first error is that you appear not to be using the settings that you edited. The error shows that it is trying to connect to localhost, which is what it does when the HOST section in the DATABASES setting is missing.

The second looks like it's from incorrect/incomplete configuration of whitenoise, so you will have to look at your settings and the whitenoise documentation to work out what the issue is there.

ok, do you mean that I am not correctly placing the information that pythonanywhere "databases" gives me in my settings.py file? I'm reviewing what I put in settings.py and I replaced that information, in fact inside my settings.py nothing points to localhost, do I have to point it to localhost or am I based on the databases page? It could also be an ALLOWED_HOSTS error = and should I add something there?

About the second thanks!! I'm gonna check my whitenoise out

I mean in database section I have a field called "address", that info I placed in 'HOST' which is inside my database configuration in settings.py. Is that ok? I mean I don't know why tries to connect to localhost

Yes, the address field from the Databases page should be fine. Are you still getting the error, though? Do you see the same errors at the bottom of your error log?

ok, at the bottom at the error log page shows me this:

enter code here
File "/home/ItzelAnaid/env/lib/python3.10/site-packages/django/templatetags/static.py", line 113, in url
return self.handle_simple(path)
File "/home/ItzelAnaid/env/lib/python3.10/site-packages/django/templatetags/static.py", line 129, in handle_simple
return staticfiles_storage.url(path)
File "/home/ItzelAnaid/env/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 166, in url
return self._url(self.stored_name, name, force)
File "/home/ItzelAnaid/env/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 145, in _url
hashed_name = hashed_name_func(*args)
File "/home/ItzelAnaid/env/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 465, in stored_name
raise ValueError(
ValueError: Missing staticfiles manifest entry for 'assets/images/favicon.ico'

and Bad Request error (500) is appered in my website

so do I have to check out the last bug or I have to see every bug is in my error log page? So my main trouble is in staticfiles? I don't get it :(

The error log will show a traceback when there is an error. If a page is accessed twice, the error will appear twice. It does look like your main issue is your static files configuration, so check that and make sure it's referencing directories and URLs that exist and then run collectstatic.

great! thanks for helping me :D I'm gonna check my static files