Connection Refused Issue with Typesense and Nginx Reverse Proxy
TLDR Karthik experiences a connection refused problem with Typesense and Nginx reverse proxy. Jason helps troubleshoot, but the issue remains unresolved.


Mar 17, 2023 (6 months ago)
Karthik
11:07 PM#try_files $uri $uri/ =404;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
} I an getting a connection refused with typsense; xhr.js?4381:210 POST http://localhost:8108/multi_search?x-typesense-api-key=xyz net::ERR_CONNECTION_REFUSED I am assuming I should also add typesense to proxy_pass; is that correct? if so how do i add?Any help will be appreciated to resolve this issue
Jason
11:18 PMJason
11:18 PMJason
11:19 PMpx aux | grep typesense-server
give you any results?Mar 18, 2023 (6 months ago)
Srini
12:22 AMSrini
12:27 AMLoaded: loaded (/etc/systemd/system/typesense-server.service; enabled; preset: enabled)
Active: active (running) since Sat 2023-03-18 00:20:35 UTC; 5min ago
Docs: https://typesense.org
Main PID: 100800 (typesense-serve)
Tasks: 107 (limit: 2225)
Memory: 23.7M
CPU: 350ms
CGroup: /system.slice/typesense-server.service
└─100800 /usr/bin/typesense-server --config=/etc/typesense/typesense-server.ini
Mar 18 00:20:35 acureach systemd[1]: Started Typesense Server.
Mar 18 00:20:35 acureach typesense-server[100800]: Log directory is configured as: /var/log/typesense
Mar 18 00:20:35 acureach typesense-server[100800]: E20230318 00:20:35.443630 100938 raft_server.h:62] Peer refresh failed, error: Doing another configuration change
Jason
12:48 AMsudo netstat -nlp | grep :8108
Jason
12:49 AMdate ; tail -100 /var/log/typesense/typesense.log
Jason
12:50 AMcurl
Srini
12:59 AMSrini
12:59 AMtypesense 158688 root 23u IPv4 789450 0t0 TCP *:8108 (LISTEN)
Srini
01:00 AMJason
01:01 AMJason
01:01 AM> http://localhost:8108/multi_search?x-typesense-api-key=xyz net::ERR_CONNECTION_REFUSED
That will only show up if somehow port 8108 is not accessible by whatever app is throwing that error
Jason
01:02 AMSrini
01:02 AMSrini
01:02 AMtcp 0 0 0.0.0.0:8108 0.0.0.0:* LISTEN 158688/typesense-se
Jason
01:04 AMJason
01:05 AMJason
01:05 AM<https://acureach.in/search>
and have nginx reverse proxy just that path to TypesenseJason
01:06 AMJason
01:06 AMlocation /search {
rewrite /search/(.*) /$1 break;
proxy_pass ;
proxy_redirect off;
proxy_set_header Host $host;
}
Srini
01:08 AMSrini
01:08 AM#try_files $uri $uri/ =404;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /multi_search {
proxy_pass http://localhost:8108;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
Jason
01:11 AMSrini
01:11 AMJason
01:11 AMSrini
01:13 AM168.149.146.41 - - [18/Mar/2023:01:12:32 +0000] "GET /_next/static/chunks/pages/_error.js?ts=1679101951333 HTTP/1.1" 200 1445 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
168.149.146.41 - - [18/Mar/2023:01:12:33 +0000] "GET /_next/static/development/_buildManifest.js?ts=1679101951333 HTTP/1.1" 200 364 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
168.149.146.41 - - [18/Mar/2023:01:12:33 +0000] "GET /_next/static/chunks/main.js?ts=1679101951333 HTTP/1.1" 200 1114746 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
168.149.146.41 - - [18/Mar/2023:01:12:33 +0000] "GET /_next/static/development/_ssgManifest.js?ts=1679101951333 HTTP/1.1" 200 76 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
168.149.146.41 - - [18/Mar/2023:01:12:33 +0000] "GET /_next/static/chunks/pages/_app.js?ts=1679101951333 HTTP/1.1" 200 888937 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:35 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 158 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
168.149.146.41 - - [18/Mar/2023:01:12:36 +0000] "GET /favicon.ico HTTP/1.1" 304 0 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
168.149.146.41 - - [18/Mar/2023:01:12:36 +0000] "GET /_next/static/development/_devMiddlewareManifest.json HTTP/1.1" 200 12 "https://acureach.in/multi_search?x-typesense-api-key=xyx" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:37 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 156 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:40 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 158 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:46 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 158 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:46 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 314 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:46 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 470 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
24.44.64.232 - - [18/Mar/2023:01:12:46 +0000] "GET /_next/webpack-hmr HTTP/1.1" 101 659 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
Srini
01:13 AMJason
01:13 AMSrini
01:14 AMSrini
01:14 AM2023/03/18 01:12:11 [error] 8671#8671: *26307 connect() failed (111: Connection refused) while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://127.0.0.1:3000/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:12 [error] 8671#8671: *26310 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:12 [error] 8672#8672: *26311 connect() failed (111: Connection refused) while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://[::1]:3000/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:12 [error] 8672#8672: *26311 connect() failed (111: Connection refused) while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://127.0.0.1:3000/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:13 [error] 8671#8671: *26314 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:14 [error] 8671#8671: *26315 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:17 [error] 8671#8671: *26316 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:17 [error] 8672#8672: *26317 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:18 [error] 8672#8672: *26319 no live upstreams while connecting to upstream, client: 168.149.146.41, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:19 [error] 8672#8672: *26320 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:20 [error] 8672#8672: *26321 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:20 [error] 8672#8672: *26322 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:22 [error] 8672#8672: *26323 no live upstreams while connecting to upstream, client: 52.129.0.102, server: acureach.in, request: "GET /_next/webpack-hmr HTTP/1.1", upstream: "http://localhost/_next/webpack-hmr", host: "acureach.in"
2023/03/18 01:12:27 [error] 8672#8672: *26328 no live upstreams while connecting to upstream, client: 24.44.64.232, server: acureach.in, request: "GET / HTTP/1.1", upstream: "http://localhost/", host: "acureach.in", referrer: "https://acureach.in/"
2023/03/18 01:12:30 [error] 8671#8671: *26353 no live upstreams while connecting to upstream, client: 168.149.146.41, server: acureach.in, request: "GET /_next/static/webpack/d31f7b7411543aac.webpack.hot-update.json HTTP/1.1", upstream: "http://localhost/_next/static/webpack/d31f7b7411543aac.webpack.hot-update.json", host: "acureach.in", referrer: "https://acureach.in/multi_search?x-typesense-api-key=xyx"
Srini
01:15 AMJason
01:15 AMCould you first visit the site, generate a multi_search request, and then post the lines from the logs?
Jason
01:16 AMSrini
01:16 AM

Srini
01:17 AM
Srini
01:17 AMJason
01:18 AMJason
01:19 AMJason
01:19 AMSrini
01:20 AMnginx - nodejs
nginx - typenses-adapter
Jason
01:20 AMJason
01:20 AMSrini
01:24 AMSrini
01:32 AM
Typesense
Indexed 2764 threads (79% resolved)
Similar Threads
Resolving Connection Issues on Ubuntu 21.10
Philipe faced a problem with TypeSense running on Ubuntu 21.10. After troubleshooting, Jason and Kishore Nallan suggested a binary to solve the compatibility issue, which resolved the issue.


Changing Path for Typesense Server Configuration
Karthik wanted to change the path in Typesense server config. Jason suggested updating the nodes and using Nginx reverse proxy for the desired configuration.
Troubleshooting Typesense Docsearch Scraper Setup Issue
Vinicius experienced issues setting up typesense-docsearch-scraper locally. Jason identified a misconfiguration with the Typesense server after checking the .env file, and recommended using ngrok or port forwarding for development purposes. Vinicius successfully resolved the issue with port forwarding.


Typesense Error in Unit Testing for Python
Mehdi was encountering errors while running unit tests for Typesense functionalities in Python. Through discussion with Kishore Nallan, they recognized resource constraints might be causing the issue during JSONL file import. As suggested by Kishore Nallan, adding a short sleep after the import resolved the problem.
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.