Are you set "ALLOWED_HOSTS" in settings.py for "172.21.48.1" ? ในวันที่ วันพุธที่ 31 พฤษภาคม ค.ศ. 2023 เวลา 14 นาฬิกา 38 นาที 48 วินาที UTC+7 Robbi Nespu เขียนว่า:
> > Hello, > I am using windows machine to develop django project but now i want to > make my program run on WSL and keep the DB are running on host (windows > machine), > > This mean the Django program inside WSL will try to connect to postgresql > on WINDOWS. > > > > > $ cat /etc/resolv.conf | grep name > > nameserver 172.21.48.1 > > > The NMAP show the IP and PORT are correct > > > > > $ nmap -p 5432 172.21.48.1 > > Starting Nmap 7.80 ( https://nmap.org ) at 2023-05-31 15:26 +08 > > Nmap scan report for WINDOWSMACHINE.mshome.net (172.21.48.1) > > Host is up (0.00049s latency). > > > > PORT STATE SERVICE > > 5432/tcp filtered postgresql > > > > Nmap done: 1 IP address (1 host up) scanned in 0.24 seconds > > > This are my setting-database > > > DATABASES = { > > 'default': { > > 'ENGINE': 'django.db.backends.postgresql', > > 'NAME' : 'LMHOST', > > 'USER' : 'postgres', > > 'PASSWORD' : '', > > 'HOST': '172.21.48.1', > > 'PORT': 5432, > > } > > } > > but the connection cannot be established. Here the output I get > > > $ python manage.py migrate > > Traceback (most recent call last): > > File > "/home/robbi/.virtualenvs/DJANGO_VIRTUALENV/lib/python3.9/site-packages/django/db/backends/base/base.py", > > line 289, in ensure_connection > > self.connect() > > File > "/home/robbi/.virtualenvs/DJANGO_VIRTUALENV/lib/python3.9/site-packages/django/utils/asyncio.py", > > line 26, in inner > > return func(*args, **kwargs) > > File > "/home/robbi/.virtualenvs/DJANGO_VIRTUALENV/lib/python3.9/site-packages/django/db/backends/base/base.py", > > line 270, in connect > > self.connection = self.get_new_connection(conn_params) > > File > "/home/robbi/.virtualenvs/DJANGO_VIRTUALENV/lib/python3.9/site-packages/django/utils/asyncio.py", > > line 26, in inner > > return func(*args, **kwargs) > > File > "/home/robbi/.virtualenvs/DJANGO_VIRTUALENV/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", > > line 275, in get_new_connection > > connection = self.Database.connect(**conn_params) > > File > "/home/robbi/.virtualenvs/DJANGO_VIRTUALENV/lib/python3.9/site-packages/psycopg/connection.py", > > line 728, in connect > > raise ex.with_traceback(None) > > psycopg.OperationalError: connection failed: server closed the > connection unexpectedly > > This probably means the server terminated abnormally > > before or while processing the request. > > > any clue on this? I have already tried disable firewall but still no luck > > -- > Regards > Robbi Nespu > > PGP: D311 B5FF EEE6 0BE8 9C91 FA9E 0C81 FA30 3B3A 80BA > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1c9881bc-ef4d-493a-b1e9-96866e59e7dbn%40googlegroups.com.

