http://localhost:9000/admin/store/ net::ERR_CONNECTION_REFUSED

feerdispzoo

Verified User
Joined
Jan 17, 2022
Messages
189
I try running React App (medusa.js).

medusa server is running on port 9000 medusa admin is running on port 7001 medusa storefront is running on port 8000

Now I add reverse proxy in nginx configuration:

server
{
listen my_public_ip:80;
server_name api.aray.pl www.api.aray.pl ;
access_log /var/log/nginx/domains/api.aray.pl.log;
access_log /var/log/nginx/domains/api.aray.pl.bytes bytes;
error_log /var/log/nginx/domains/api.aray.pl.error.log;
root /home/node/domains/api.aray.pl/public_html;
index index.php index.html index.htm;
include /usr/local/directadmin/data/users/node/nginx_php.conf;
# Mail auto configuration (Thunderbird, MS Outlook)
location ~ "^/\.well-known/autoconfig/mail/config-v1\.1\.xml$|^/([Aa]utodiscover)/\1\.xml$" {
proxy_pass http://my_public_ip:9000;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
}
location /
{
# access_log off;
proxy_buffering off;
proxy_pass http://my_public_ip:7001;
}
location /nginx_static_files/
{
# access_log /var/log/nginx/access_log_proxy;
alias /home/node/domains/api.aray.pl/public_html/;
internal;
}
include /etc/nginx/webapps.conf;
}

Error: Storefront and admin panel working under domain but api not working because:

GET http://localhost:9000/admin/store/ net::ERR_CONNECTION_REFUSED

This is for all endpoints.

Unfortunately, I don't know why the clutcher tries to get localhost instead of setting the endpoint to my domain name, e.g. http://api.aray.pl/admin/store/
 
server_name api.aray.pl www.api.aray.pl ;
You got some DNS issues here. I don't work with nGxinx, but normally we don't use www on subdomains.
I get a different result visiting http://api.aray.pl (which is normal) and http://www.api.aray.nl (which is normally not used or redirected).

Visiting the site with www instantly gives a https and erorr page with this error:
SSL_ERROR_NO_CYPHER_OVERLAP

Visiting the site just with api.aray.pl gives me the name "medusa" in my tab display, but gives a blank page and keeps loading.

Normally a subdomain with and without www should point to the same place so I would start there fixing things.
 
@Richard G,
basically this is ngnix conf generatd by directadmin. I edit only proxy_pass to port 7001

Visiting the site just with api.aray.pl gives me the name "medusa" in my tab display, but gives a blank page and keeps loading.
>> you need to wait a moment then you see login form. This is time loading because in browser console you can see is most of error with fetching data from api.

After you see login form then please see console errors:
Failed to load resource: net::ERR_CONNECTION_REFUSED
localhost:9000/admin/auth:1


Failed to load resource: net::ERR_CONNECTION_REFUSED
main.bundle.js:10 Error: Network Error
at e.exports (main.bundle.js:1:53770)
at v.onerror (main.bundle.js:1:48310)
f @ main.bundle.js:10
y @ main.bundle.js:10
(anonymous) @ main.bundle.js:10
Promise.catch (async)
v @ main.bundle.js:10
(anonymous) @ main.bundle.js:10
main.bundle.js:1


GET http://localhost:9000/admin/auth net::ERR_CONNECTION_REFUSED
(anonymous) @ main.bundle.js:1
e.exports @ main.bundle.js:1
e.exports @ main.bundle.js:1
c.request @ main.bundle.js:1
(anonymous) @ main.bundle.js:1
request @ main.bundle.js:1
getSession @ main.bundle.js:1
(anonymous) @ main.bundle.js:10
fetchFn @ main.bundle.js:10
v @ main.bundle.js:10
(anonymous) @ main.bundle.js:10


But i dont know why this GET api request to:
localhost:9000/admin/auth:1

Port 9000 is medusa server, port 7001 is admin medusa which is set reverse proxy to domain api.aray.pl. So i think should fetch api from localhost:7001 or api.aray.pl:7001 or directly from api.aray.pl

I've been working on this for about 15 hours and I'm running out of ideas.
 
Back
Top