Could not translate host name to address: Temporary failure in name resolution

Luca Zanna 96 Reputation points
2021-06-26T14:05:49.027+00:00

Dear Support,

I have a PostgreSQL database on Azure and I connect it to via Python.

It worked well until yesterday, and starting today I have the following error message:
OperationalError: (psycopg2.OperationalError) could not translate host name "server_name.postgres.database.azure.com" to address: Temporary failure in name resolution

I have not changed anything in the configuration of the database or my Python script.

Here is what the script looks like:
import pandas as pd
from sqlalchemy import create_engine

engine = create_engine('postgresql+psycopg2://user:password@Testta _name:5432/database_name?sslmode=require')
df = pd.read_csv('my_file.csv')
df.to_sql('table_name',engine, if_exists = 'replace', index=False)

Do you know what could be the issue?

thank you!

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. Luca Zanna 96 Reputation points
    2021-06-28T13:48:06.103+00:00

    Thank you @AnuragSharma-MSFT, we can close this post.

    A simple restart of Python was able to fix this.

    Regards

    Luca


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.