# django.db.utils.OperationalError: could not translate host name "neighbornook-database.flycast" to address: nodename nor servname provided, or not known

**URL:** <https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811>\
**Category:** Django\
**Tags:** postgres\
**Created:** [July 13, 2024, 4:39pm UTC](https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811 "2024-07-13T16:39:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinstavrakov](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/martinstavrakov/32/36916_2.png) [@martinstavrakov](https://community.fly.io/u/martinstavrakov)\
**Post date:** [July 13, 2024, 4:39pm UTC](https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811/1 "2024-07-13T16:39:06Z")

</div>

Hello, I have a project running on django and postgres. When I run it on fly it works as I created a superuser and I can login to the admin page. However when I try running it locally or do a migration I get this error “django.db.utils.OperationalError: could not translate host name “neighbornook-database.flycast” to address: nodename nor servname provided, or not known”.  
This is how I implemented the Database into my settings.py DATABASE\_URL=os.getenv(“DATABASE\_URL”)

if DATABASE\_URL:  
DATABASES = {  
‘default’: dj\_database\_url.parse(DATABASE\_URL),  
}  
else:  
DATABASES = {  
‘default’: {  
‘ENGINE’: ‘django.db.backends.sqlite3’,  
‘NAME’: BASE\_DIR / ‘db.sqlite3’,  
}  
}  
And this is how I have my DATABASE\_URL in my .env file: DATABASE\_URL=postgres://neinook\_bd:HiJVm@neighbornook-database.flycast:5432/nek\_backend

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [July 13, 2024, 4:47pm UTC](https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811/2 "2024-07-13T16:47:56Z")

</div>

> **[Private Networking](https://fly.io/docs/networking/private-networking/)**
>
> Documentation and guides from the team at Fly.io.

`.flycast` is private (internal in fly’s infra), ie it’s not accessible outside of the org’s fly machines… ie it won’t work locally b/c your machine has no idea what `.flycast` is.

---

<div class="post-metadata">

**Author:** ![martinstavrakov](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/martinstavrakov/32/36916_2.png) [@martinstavrakov](https://community.fly.io/u/martinstavrakov)\
**Post date:** [July 13, 2024, 5:15pm UTC](https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811/3 "2024-07-13T17:15:59Z")

</div>

Hello, thank you for your response. I am new to programming I’m learning now and also this is my first time using fly. I looked into the documentation that you provided but I do not understand completely how to resolve the issue. I want to ask if I remove the fly database from my settings.py will it still work when I make changes locally and deploy it? Meaning all the modules and information I put locally will it connect to the fly database when I deploy it?

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [July 13, 2024, 5:28pm UTC](https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811/4 "2024-07-13T17:28:10Z")

</div>

> [@martinstavrakov](#):
>
> DATABASE\_URL

You need to set this to use `.fly.dev` in the environment where you’re deploying (local machine or in CI/CD). You’ll still want to use `.flycast` in your app’s environment though, that way it’ll communicate internally in the app instance rather than making an external network call to itself.

Also, I hope you didn’t leak your DB name/password in your first post, you should rotate the creds if those are the real creds.

---

<div class="post-metadata">

**Author:** ![martinstavrakov](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/martinstavrakov/32/36916_2.png) [@martinstavrakov](https://community.fly.io/u/martinstavrakov)\
**Post date:** [July 13, 2024, 5:51pm UTC](https://community.fly.io/t/django-db-utils-operationalerror-could-not-translate-host-name-neighbornook-database-flycast-to-address-nodename-nor-servname-provided-or-not-known/20811/5 "2024-07-13T17:51:59Z")

</div>

Ok so I have to set the VPN with WireGuard in order to use both my local and fly database. thank you!
