TLDR Karthik experiences a connection refused problem with Typesense and Nginx reverse proxy. Jason helps troubleshoot, but the issue remains unresolved.
If you’re trying to connect to Typesense running on 8108, you don’t need to run it through nginx
It sounds like typesense server is not running based on the connection refused error
Does `px aux | grep typesense-server` give you any results?
Jason replying as Karthik left home; typesense is running. We are trying to configure the nextjs app on nodejs proxied by nginx and the app has a typesnse searchbar
Jason ● typesense-server.service - Typesense Server
Loaded: 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:
Could you run and share the output of this: ```sudo netstat -nlp | grep :8108```
Could you also share the output of the following: ```date ; tail -100 /var/log/typesense/typesense.log```
And also this:
```curl
Jason lsof -i :8108
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME typesense 158688 root 23u IPv4 789450 0t0 TCP *:8108 (LISTEN)
{"ok":true}
Ok so Typesense is running and is healthy
From the very first message:
>
Are you running on docker?
no we are notu using docker
sudo netstat -nlp | grep :8108 tcp 0 0 0.0.0.0:8108 0.0.0.0:* LISTEN 158688/typesense-se
you can access
It looks like the Typesense hostname is just configured as
I see what you’re trying to do now
You probably want to have Typesense behind say `
You want something like this in your nginx config:
```location /search {
rewrite /search/(.*) /$1 break;
proxy_pass
I already did this
location / {
#try_files $uri $uri/ =404;
proxy_pass
Could you post the last few logs from the nginx error log file?
just a note this works perfectly fine in local laptop it only happens in cloud wuth nginx reverse proxy
I see a HTTP 500 thrown for that path, so should show some error in the nginx log file
24.44.64.232 - - [18/Mar/2023:01:12:32 +0000] "GET /_next/static/webpack/webpack.7a7305f32c49b41c.hot-update.js HTTP/1.1" 200 858 "
that is from access.log
You want to look at error.log
this is from error.log
2023/03/18 01:12:11 [error] 8671#8671: *26307 connect() failed (111: Connection refused) while connecting to upstream, client: 24.44.64.232, server:
I don’t see any requests to multi_search here… Could you first visit the site, generate a multi_search request, and then post the lines from the logs?
do need to add upstream tag in nginx config?
My nginx knowledge might be outdated, but afaik, that shouldn’t be needed
btw Thank you so much for helping us on a Friday evening
I really appreciate yoru help
nothing is coming in error.log when id do the search
Is something else in front of nginx that could be catching that request and throwing a 500?
Because the multi_search request I see generated by the frontend has to show up either in access log or error log
if it doesn’t show up in either places, it’s not reaching this nginx server
nothing is infront of nginx : the config is like this :--> nginx - nodejs nginx - typenses-adapter
Could you try debug just this:
search the logs for a POST request to multi_search
I don;t think it is a nginx problem, it is somewhere in config of Nextjs and typsense adapter
Jason have a good night.
Karthik
Fri, 17 Mar 2023 23:07:00 UTCwe are running the following on ubuntu on vultr : nginx reverse proxy, nextjs apps on node on localhost:3000; typesense on localhost:8108; Here is my current nginx config; location / { #try_files $uri $uri/ =404; proxy_pass;
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 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