Typesense Connection Error on AWS EC2 Instance
TLDR Raj reported an error related to Typesense in AWS EC2 instance. After several suggestions, the issue was resolved by changing the TYPESENSE_HOST value in the .env file from "localhost" to "127.0.0.1".
1
Jun 08, 2023 (6 months ago)
Raj
09:49 AMBelow is my env file
TYPESENSE_API_KEY=xyz
TYPESENSE_HOST=host.docker.internal
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
Below is the error I am getting while running docker run command
traceback (most recent call last):
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 398, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fd4f7f63a60>: Failed to establish a new connection: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='host.docker.internal', port=8108): Max retries exceeded with url: /collections/support2_1686217630 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd4f7f63a60>: Failed to establish a new connection: [Errno -2] Name or service not known'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/seleuser/src/index.py", line 117, in <module>
run_config(environ['CONFIG'])
File "/home/seleuser/src/index.py", line 44, in run_config
typesense_helper.create_tmp_collection()
File "/home/seleuser/src/typesense_helper.py", line 32, in create_tmp_collection
self.typesense_client.collections[self.collection_name_tmp].delete()
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/typesense/collection.py", line 22, in delete
return self.api_call.delete(self._endpoint_path())
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/typesense/api_call.py", line 158, in delete
return self.make_request(requests.delete, endpoint, True,
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/typesense/api_call.py", line 129, in make_request
raise last_exception
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/typesense/api_call.py", line 103, in make_request
r = fn(url, headers={ApiCall.API_KEY_HEADER_NAME: self.config.api_key}, **kwargs)
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/requests/api.py", line 157, in delete
return request("delete", url, **kwargs)
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/home/seleuser/.local/share/virtualenvs/seleuser-AdYDHarm/lib/python3.10/site-packages/requests/adapters.py", line 565, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='host.docker.internal', port=8108): Max retries exceeded with url: /collections/support2_1686217630 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd4f7f63a60>: Failed to establish a new connection: [Errno -2] Name or service not known'))
Jason As suggested in this thread https://github.com/typesense/typesense/issues/668, I added inbound/outbound rules to allow port8108 with 0.0.0.0/0 but issue is not resolved..
Sergio
10:09 AMRaj
10:36 AM$ docker run -it --env-file=/path/to/your/.env -e "CONFIG=$(cat config.json | jq -r tostring)" typesense/docsearch-scraper:0.6.0
Sergio
10:55 AM--network="host"
like thisdocker run -it --env-file=/path/to/your/.env -e "CONFIG=$(cat config.json | jq -r tostring)" --network="host" typesense/docsearch-scraper:0.6.0
Raj
07:54 PMJason
07:58 PMJason
07:59 PM--network="host"
if you’re using the flag above)Jun 13, 2023 (6 months ago)
Raj
02:20 AMlocalhost
to 127.0.0.1
thank you Sergio Jason
1
Jason
02:27 AMTypesense
Indexed 3011 threads (79% resolved)
Similar Threads
Stability Issues with Self-Hosted Typesense Server on AWS ECS
Ryan reports stability issues with a self-hosted typesense server, whilst Jason suggests various potential factors to consider, including configuration, CPU allocation, modifying the healthcheck, and testing on EC2 instances. However, no definitive solution is reached.
Error Running Docsearch-Scraper from Docker
Rubai encountered an error running docsearch-scraper from Docker. Jason advised checking a specific Typesense documentation section for a solution.
Typesense Search Functionality Issue on CentOS Client Server
Shabber is facing an issue with Typesense search functionality on a CentOS client server. The curl request works, but not from JS. The issue remains unresolved, and Shabber will request the public IP of the server and enable port 8108.
Resolving Issues with Infix and Prefix in Query Searches
Daren struggled with searches missing values in production. Jason and Kishore Nallan offered insights and created new features to help solve the problem, which was then tested and deployed by Daren.
Troubleshooting Typesense Server Error on Docker
vikram was facing an error with Typesense Server Docker container and loss of data on restart. Kishore Nallan guided to avoid mounting tmp directory from localhost and explained stopping the Docker container.