dr5hn / countries-states-cities-database

🌍 Discover our global repository of countries, states, and cities! 🏙️ Get comprehensive data in JSON, SQL, PSQL, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities
https://dr5hn.github.io/countries-states-cities-database/
Open Data Commons Open Database License v1.0
7.2k stars 2.52k forks source link

500 Error everyday after 10pm IST #809

Closed sushant-gvw closed 2 months ago

sushant-gvw commented 2 months ago

ERROR 2024-07-05 23:15:13,701 log log.py 241 log_response Internal Server Error: /events/event_details_edit/eb742c5f-fa62-4c1e-b657-5ad07d6fd761 Traceback (most recent call last):   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connection.py", line 203, in _new_conn     sock = connection.create_connection(   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/util/connection.py", line 60, in create_connection     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):   File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo     for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -3] Temporary failure in name resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connectionpool.py", line 790, in urlopen     response = self._make_request(   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connectionpool.py", line 491, in _make_request     raise new_e   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connectionpool.py", line 467, in _make_request     self._validate_conn(conn)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn     conn.connect()   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connection.py", line 611, in connect     self.sock = sock = self._new_conn()   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connection.py", line 210, in _new_conn     raise NameResolutionError(self.host, self, e) from e urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x7f8a86e72730>: Failed to resolve 'api.countrystatecity.in' ([Errno -3] Temporary failure in name resolution)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/requests/adapters.py", line 486, in send     resp = conn.urlopen(   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/connectionpool.py", line 844, in urlopen     retries = retries.increment(   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/urllib3/util/retry.py", line 515, in increment     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.countrystatecity.in', port=443): Max retries exceeded with url: /v1/countries (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f8a86e72730>: Failed to resolve 'api.countrystatecity.in' ([Errno -3] Temporary failure in name resolution)"))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner     response = get_response(request)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response     response = wrapped_callback(request, *callback_args, callback_kwargs)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view     return view_func(request, *args, *kwargs)   File "/home/gvwl7admin/gvw_momentum/iam/custom_decorators.py", line 21, in wrapped_view     return view_func(request, args, kwargs)   File "/home/gvwl7admin/gvw_momentum/townHall/views.py", line 616, in event_details_edit     countries_data=get_countries()   File "/home/gvwl7admin/gvw_momentum/townHall/views.py", line 215, in get_countries     response = requests.request("GET", url, headers=headers)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/requests/api.py", line 59, in request     return session.request(method=method, url=url, kwargs)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/requests/sessions.py", line 589, in request     resp = self.send(prep, send_kwargs)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/requests/sessions.py", line 703, in send     r = adapter.send(request, kwargs)   File "/home/gvwl7admin/gvw_momentum/events_env/lib/python3.8/site-packages/requests/adapters.py", line 519, in send     raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.countrystatecity.in', port=443): Max retries exceeded with url: /v1/countries (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f8a86e72730>: Failed to resolve 'api.countrystatecity.in' ([Errno -3] Temporary failure in name resolution)"))**

sushant-gvw commented 2 months ago

But that rate limit issue comes only from 10PM to 8 AM. Is it conincidence?? and also I believe we are not surpassing 980 requests.I can confirm on this after using seperate API key for production.Thank you for your quick response.@dosu

dr5hn commented 2 months ago

@sushant-gvw Ignore @dosubot There are no rate limit enforced. If you say you get 500 errors post 10pm.

But I have a Uptime service setup for API which hits every 5 minutes to check uptime of the API. https://stats.uptimerobot.com/VZ2NqHlJYM/788153841 Haven't got any notifications so far of API being down continuously after 10pm.

I did run multiple tests after 10pm yesterday and it just worked fine. Have also setup a cron job on server to ping API route every 10 minutes. seems to be loading fine.

Looks like some issue on your end.

dosubot[bot] commented 2 months ago

There are no rate limits enforced on the api.countrystatecity.in service, and the uptime monitoring indicates that the API is functioning correctly after 10 PM IST .

Given that the issue seems to be specific to your environment, you might want to investigate the following potential causes:

  1. Scheduled Tasks or Cron Jobs: Check if there are any scheduled tasks, cron jobs, or maintenance scripts running after 10 PM IST that might affect DNS resolution or network connectivity .
  2. Network Configuration or Firewall Rules: Verify if there are any network configurations or firewall rules that change after 10 PM IST, potentially affecting the ability to resolve external domains .
  3. DNS Caching Mechanisms: Investigate if there is any caching mechanism in place for DNS lookups, and check configurations or logs for issues with DNS cache expiration or refresh after 10 PM IST .
  4. External API Calls or Services: Determine if other external API calls or services accessed by your application experience similar issues after 10 PM IST, indicating a broader network or DNS resolution problem .
  5. DNS Servers: Check if there are specific DNS servers configured for your application and if they have any known issues or maintenance schedules that could affect DNS resolution after 10 PM IST .

These steps should help you identify and resolve the underlying issue causing the 500 errors after 10 PM IST.

To continue talking to Dosu, mention @dosu.