can't restore my site back after adding allowed_hosts = ['*']

the latest thing i have reached too
is this error
when i go to admin page i got it


same problem regarding to database on digital ocean as there is nothing in the database but i allowed of null in some fields that may be doesn’t exist at the beginneng
anyway i have to search on models field to see if there are some fields causing the database to stall
also when i go to home i noticed this on chrome console and network

it fails to open home view as it may search for some objects that home model views return to template but as it’s null and that’s ok in the beginning it stay long time so break
what is that mean bro if you have any idea please
if i can’t find a solution i will rebuild the site again and test every app individually with database

Again, this has nothing to do with any code that you’ve written or the contents of any model. It is not caused by any field definitions. It is not caused by any data that may or may not be in any tables.

This error is happening before Django even has a chance to run any of your code. Django hasn’t even completed its internal initialization since it can’t even connect to the database.

The cause of this problem is something in your settings, either directly or in the environment variables that you are setting. There is no reason to be spending any time looking at anything else.

okay brother i understand that

here are another problem regarding my postgresql installation, that we may have talk about it in this issue

i have installed postgresql 14 before using it’s installer.dmg file and edited it’s pg_hba.conf file

a lot of 14 versions updates was installed later using installer also and it was override the old

But after 15 version has been launched i install it using the same way as before

without searching if it is correct or not i thought it will override the previous one but as it’s a total new different major version i have now two instances of postgresql

two instances in library folder and i can open the 15 version postgresql.conf file but

i can’t open the 15 version pg_hba.conf using vs code

enter image description here

also can’t open the 15 server how to fix this issue any suggestion please

enter image description here

do i have to uninstall version 14 and reinstall 15 again

It’s very unlikely that I’m going to be able to diagnose a PostgreSQL installation problem. What I can tell you is that multiple instances and versions of PostgreSQL do co-exist quite nicely on the same system, as long as there are no conflicts with directories, files, TCP ports or sockets.

okay bro really i appreciate every word you have said as you are the most precious person i knew really
anyway it seems that i have to read some docs in postgresql although i don’t like their docs system and manuals but i will try to solve that
thanks a lot brother @KenWhitesell

Hello Brother @KenWhitesell How are you? hope everything is fine,
now regarding to this problem
i have found that the problem was caused by the launch.json file settings for chrome
and i also was putting cors origin header to only 8080
i now made it

CORS_ORIGIN_WHITELIST = (
    'http://localhost:8080',
    'https://localhost:8080',
    "http://127.0.0.1:8080",
    "https://127.0.0.1:8080",
    'http://localhost:8000',
    'https://localhost:8000',
    "http://127.0.0.1:8000",
    "https://127.0.0.1:8000",
    "https://starfish-app-xgsam.ondigitalocean.app"
)

just for testing purposes but, when i try to runserver it try to running at 8000 and that fail
cause the site trying to reach https while it doesn’t support https
now i can’t secure shell to digital ocean app platform the never provide this feature to install Nignx server
or enable https
so i have changed the settings of django to run on other default port number other than 8000
i made it run on 8080 as in launch.json and also any other port other than that it works fine locally
and i was able to restore it after deleting the cookies data
but i have another problem
i don’t know why my database settings is not working
it was working fine previously but now
either i got timed out

django.db.utils.OperationalError: connection to server at "database-1.cdhuqyydpuae.eu-central-1.rds.amazonaws.com" (3.125.202.78), port 5342 failed: Connection timed out
        Is the server running on that host and accepting TCP/IP connections?

or
specify engine value
or

connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory

so my last problem is how to connect to the rds aws database
i already enabled all possible inbound rules but never work
i don’t know what to do
and can’t go further anymore
i think that has relation to my double instances of postgress versions installed locally
14 or 14.5 and 15, while it was on aws rds, was 14.5
what i don’t understand really
how can the site work on any other different port other than 8000 and still never work on 8000 again after all that
launch.json chrome settings

        {
            "name": "Launch Chrome",
            "request": "launch",
            "type": "chrome",
            "url": "[https://localhost:8080, http://localhost:8080, https://localhost:8000, http://localhost:8000]",
            "webRoot": "${workspaceFolder}"
        },

also what to do with my double instances of Postgres could that cause this problem
do i use pg_upgrade command to migrate

i have tried to install Nignx loccaly from source to activate https but i have found another problem
when i am trying to configure

./configure --with-pcre=../pcre-8.45 \
    --with-zlib=../zlib-1.2.13 \
    --with-openssl=../openssl-1.1.1 \
    --with-threads \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_xslt_module \
    --with-http_image_filter_module \
    --with-http_mp4_module \
    --with-mail \
    --with-mail_ssl_module \
    --with-debug

it tells me that

checking for GD library ... not found
checking for GD library in /usr/local/ ... not found
checking for GD library in /usr/pkg/ ... not found
checking for GD library in /opt/local/ ... not found

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

and when i have tried to install this missing library using

cd ../libgd-2.3.3
./configure
make
make install

it tells me

** Configuration summary for libgd 2.3.3:

   Support for gd/gd2 images:        no
   Support for Zlib:                 yes
   Support for PNG library:          no
   Support for JPEG library:         no
   Support for WebP library:         no
   Support for HEIF library:         no
   Support for AVIF library:         no
   Support for TIFF library:         no
   Support for Freetype 2.x library: no
   Support for Fontconfig library:   no
   Support for Xpm library:          no
   Support for liq library:          no
   Support for complex text:         no
   Support for pthreads:             yes

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating config/Makefile
config.status: creating config/gdlib.pc
config.status: creating src/config.h
config.status: executing depfiles commands
config.status: executing libtool commands

and then after trying to install nignx again using make and make install
it says

make: *** No rule to make target `build', needed by `default'.  Stop.

while it was previously said

Configuration summary
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

i didn’t even find these folder exists in ther paths as there are nothing happened and now i got just folder of nignx alone in my home directory without all pcre and zlib inside

i don’t know what to do with all these problems and really i got bored and disparate and can’t go further

the problem now when change the database setting i got also another db error acc. to the change
so i am sure that there is some settings that was working fine cause rds allow all requests incoming and inbounds so i really confused and distorted by all these problems and son’t understand what happening

I’d like to help you here as far as I can, but to do so, we need to be a bit more organized about this.

First, you should take a step back and a deep breath. There may be multiple issues that all need to be addressed - and we’ll try to do so, but only one at a time.

So pick the first issue you want to address, and post the information only about that issue.

Take the time to explain that one issue only

  • include the relevant background information about the platform (which operating system? what versions of Django and Python? what database is involved?),
  • what is not working?
    • Any error messages being received? (If so, include them)

first of all i would like to thank you y brother @KenWhitesell for all caring and helping efforts

i have managed and figured out the database problem as DigitalOcean has no static IP

So i have created Database on digitalOcean platform itself instead of AWS that never accept connection from Digital Ocean, now the ongoing problems

first problem

i was trying to install Nignx Server on my Macbook Bro Latest Version Ventura 13 updated on Monterey 12

the problem is that Apache in already been merged on the system
but to attach Apache server with django it need Mod_Wasgi module
in my Environment

pip install mod_wsgi

when I run

mod_wsgi-express start-server

I got this error

No code signing authority for module at
/Users/abunagy/Projects/mysite/lib/python3.10/site-packages/mod_wsgi/server/mod_wsgi-py310.cpython-310-darwin.so
specified in LoadModule directive.
httpd (mod_wsgi-express) : Syntax error on line 163 of
/var/tmp/mod_wsgi-localhost:8000:501/httpd.conf: Code signing absent - not loading module at: /Users/abunagy/Projects/mysite/lib/python3.10/site-packages/mod_wsgi/server/mod_wsgi-py310.cpython-310-darwin.so

that mean it is not a verified application and it has to be verified in order for it to run on Mac, without it being verified and loading it in apache, the apache server will fail to start with this error:
it may be has relation to php or something that has been removed from apple silicon M1 system
so i didn’t want to complicate the problem and try to add certifications on the system for it on keychain,

as every time i had tried to work around a problem it gone worth so i left it and have tried this way

Setting up a local web server on macOS 13 “Ventura”
but no way it doesn’t do anything and i really not expert on mac system i was over 20 years windows user and this is the first mac in my life, a sold all my things and paid all what i have saved to get it, and changed my career a lot to get better job but still didn’t work yet in that field,

anyway i searched for an alternative to make that server enable https and found that Nignx do the same as apache

when i started using this mac i promised myself to use it in clean way, mean

not installing anything immediately without first see how can i uninstall it or update it, and if there is a way better than using brew package manger i go for it
ti now i never need to use brew and all my libraries are installed from sources and just path to them or using pip, if i hade to use sudo i make sure i can update or remove

anyway bro

when i tried to install Nignx using binary sources using ./configure
the PCRE wasn’t exist yet and it required it and i finally managed to get all the required packages as follows

but i was then run configure more than one time
in the beginning it was clear and told me that

Configuration summary
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

but after missing with the configure command options a lot to complete the packages i like to add from here

http://nginx.org/en/docs/configure.html

i got this next error

checking for GD library ... not found
checking for GD library in /usr/local/ ... not found
checking for GD library in /usr/pkg/ ... not found
checking for GD library in /opt/local/ ... not found
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

i found on stack overflow that i have to install all missing package same way
so i proceeded to do so with

cd ../libgd-2.3.3
./configure
make
make install

it told me that terminal output finally

Support for Zlib:                 yes
   Support for PNG library:          no
   Support for JPEG library:         no
   Support for WebP library:         no
   Support for HEIF library:         no
   Support for AVIF library:         no
   Support for TIFF library:         no
   Support for Freetype 2.x library: no
   Support for Fontconfig library:   no
   Support for Xpm library:          no
   Support for liq library:          no
   Support for complex text:         no
   Support for pthreads:             yes

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating config/Makefile
config.status: creating config/gdlib.pc
config.status: creating src/config.h
config.status: executing depfiles commands
config.status: executing libtool commands

i cd back to Nignx folder and tried to configure it again with same long command ./configure
but this time it didn’t give me the previous paths to default folders and the same error exists

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

as i never install GD at all
i ignored it this time and continue to run

make

make install

i am sudo so never need to use it but i got this error

make: *** No rule to make target `build', needed by `default'.  Stop.

i am still suspended three courses A Computer Systems Programmer_s Perspective CS 107 and going on Algorithms and data structure from Stanford University, so it’s still long journey and i started it from the applied end not from the theoretical, to find a job fast but now i have to back to the theoretical again cause i am trying to finish up my thesis about vision control, so any way bro i am not expert yet in c or apple system, forgive e on my dummy informations
now i have found this folder in my home
this is from the first try to configure
Screenshot 2022-12-25 at 6.19.13 PM

but can’t find other paths default folders a and can’t continue make install

if you have any ideas how to solve this issue hat would be great

and thanks for everything, i would tell you net problem after this one

see you bro
and have a nice day

Unfortunately, while I have used a Mac as a travel laptop, I’ve never had to try to run nginx directly in the Mac. As all my deployments are on *nix environments, I run VirtualBox on the Mac with minimal Linux installations for testing deployment-related issues.

i was dong so bro on windows as i can understand the linux need when you be on windows but as the mac has already same architecture unix based i don’t need urgently to install linux on it, anyway it seems i need to get a linux lap some day but for now as i don’t work yet so i just wanted to work around the problems for just deploying my profile site, i mean the site you were helping me along previous month,

now it’s time for problems
next one
when i connect with database i finally find the simple way to connect to database as follows

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ.get('DB_NAME'), 
        'USER': os.environ.get('DB_USER'),  
        'PASSWORD': os.getenv('DB_PASSWORD'),
        'HOST': os.environ.get('DB_HOST'), 
        'PORT': os.environ.get('DB_PORT'),  
    },
}

but when i use

DEVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True"
# productions Settings
if DEVELOPMENT_MODE is True:
    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ.get('PG_NAME'), 
        'USER': os.environ.get('PG_USER'),  
        'PASSWORD': os.getenv('PG_PASSWORD'), 
        'HOST': os.environ.get('PG_HOST'), 
        'PORT': os.environ.get('PG_PORT'),  
    },
    "test": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
    }
}
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
    if os.getenv("DB_URL", None) is None: 
        raise Exception("DATABASE_URL environment variable not defined")
    DATABASES = {'default': dj_database_url.config(default='DB_URL',)}
    if "DB_URL" in os.environ:
        DATABASES["default"] = dj_database_url.config(conn_max_age=500, ssl_require=True)
        if "CI" in os.environ:
            DATABASES["default"]["TEST"] = DATABASES["default"]

i got an error regarding to the line

DATABASES = {'default': dj_database_url.config(default='DB_URL',)}

i am sure it was right from the docs of digital ocean and i have tried another from heroku as

DATABASES = {"default": {dj_database_url.parse(os.environ.get("DB_URL")),}}

it may gives

both didn’t work i don’t know why

and now i am working fine on just simple configuration for deployment database and i can retrieve my site locally after migrate on digitalocean

in some tries it shows that some migration is not been executed


and sometime it shows that everything is fine

anyway i can run server locally using remote database and may there is some missing phots that i don’t need them in static files but the site works fine and shows up

Screenshot 2022-12-25 at 4.34.45 PM


but when i try to get my site on digitalocean by pressing the link starfish.app cause i am not profissional orknow many about deploying and get domains and transfer etc


the link should get my resources from the same database
i got an error

so i don’t understand how can i get the same resources on my local machine while can’t get it on the server that hosting the same resources
if you have an idea on what to do or maybe the static app that has only static files need something else to be done
and i will tell you about the third problem after this one
cheers and greetings and mery christmas brother

But as you’ve already discovered, some things (such as an nginx installation) is a whole lot easier on a Linux environment. Also, if you’re trying to diagnose your deployment environment, it’s going to be a whole lot easer to debug if your test environment more closely matches what you’re trying to deploy this on.

As far as the rest of the message is concerned, how many issues are you trying to address here? I see at least three that you might be referencing, but I can’t tell what it is you’re looking for me to answer.

Please let’s keep it to one issue or question per post. Otherwise, this is going to continue to be confusing.

okay bro i will do as you said

the problem now why i can’t get my site from the link provided by digital ocean while i can retrive it locally
is it because of static files missed or what
the console errors is above you can see main three missed files and i don’t know where from they come
frontello.css
app.css
students.css

Aside:
yes you are right for nginx but i always asking as there are an installation method for mac why to
use other
the problem with mod_wasgi
is there are a lot of methods to install but they told that on mac there is no except pip
so i a sure that there is something to do with nginx but i am not professional enough to find out

A 500 is a system error. If you’re getting a 500 from your site, then there’s something fundamentally going wrong. You’ll need to find whatever log files are available to identify the source of the issue.

What you are looking at from the browser is not going to provide you with sufficient information to diagnose this. You must look at the server itself.

this is my template bro i created this template in templates folder but the digital ocean server is selecting it and show it to me

i can’t see the logs from my side, the error is deduced from the digital ocean server and i can get the site locally but from their side never work

anyway i have sent them a message and waiting for the reply

If there ends up being no way for you to get access to system logs, then you should find a different provider, because you’re not going to be able to maintain a Django system without some degree of access to those logs.

they offer something called droplet that allow you to secure shell the app server but for 45 $
i choose them because they have offered 200 $ for fresh accounts for a month, so as i don’t work yet and have no any money, so i have no choice
but it seems they never reply me as i have sent so many messages to them from the morning and no one replied me and just a message that if i want to keep the ticket open replay me
when i saw this i wanted to say something bad but knew that they will never reply me by any means so
i am really feel bad it’s now near a month since i started to solve issues and trying to deploy my profile
but as you know bro nothing for free i just will keep my way if i got failed to deploy and keep studying my MSC and try again and again but not on deploy but on finishing my difficult MSc that need a lot of studying
thanks brother and see you later

last question brother
i knew what is causing the site to not working anymore locally
if i changed these settings in my local .env file to

DEVELOPMENT_MODE=False  # never ever turn to production locally
ENVIRONMENT=productions  # never ever turn to production locally

that mean the site and chrome will use these settings

if ENVIRONMENT == 'production':
    DEBUG = False
    SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", get_random_secret_key())
    CSRF_COOKIE_AGE = 31449600 
    CSRF_COOKIE_SECURE = True
    SESSION_COOKIE_SECURE = True
    SECURE_BROWSER_XSS_FILTER = True
    SECURE_CONTENT_TYPE_NOSNIFF = True
    SECURE_HSTS_INCLUDE_SUBDOMAINS = True
    SESSION_EXPIRE_AT_BROWSER_CLOSE=True
    SECURE_HSTS_SECONDS = 10    # 31536000 it would break the site forlong time if you improperly set it, set it if everything is okay
    #SECURE_HSTS_PRELOAD=True
    SECURE_REDIRECT_EXEMPT = []
    USE_X_FORWARDED_HOST=True
    SECURE_SSL_REDIRECT = True # requests over HTTP will be redirected to HTTPS
    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

and as it doesn’t support https it will give

so i just want to know what is happening exctly

and why when have changed the port in mamge.py file to

from django.core.management.commands.runserver import Command as runserver
runserver.default_port = "7000"

and restart server it works again

why i couldn’t get to the old port again and if i am back to it i found the same things happens
even if i delete all coocies and sessions

can you explain to me brother @KenWhitesell what is going on and how to back again to the old port

cause i can’t back to 8000 anymore and also lost the other port 8080

and don’t know why i can’t back to them or how

Show the log from the console where you’re running runserver when you try to run it using port 8000 or port 8080.