Question

Ubuntu 20.04 with .net core api and angular app connection refused

I have Ubuntu droplet and I was able to set up .net core api app on it to be run as a service. When I do curl -v http://localhost:5000/api/values I get proper ones. I do not need this api to be seen outside of the droplet nor do I need to access it from internet. I was able to setup angular app which I can I access online. Problem is that published angular app for some reason is not being able to connect to this .net core api service nor able to get api url at all. The only thing I can see in chrome is connection refused and that is all. I’ve checked access.log and error.log but they will not provide any kind of info since my guess I am not accessing from external network aka internet. Does any one know what did I miss or what else needs to be setup in order for my angular app to be able to get to http://localhost:5000/api? I can provide additional details for config of nginx but not sure how it can be relevant.

Subscribe
Share

Here is my config file for site that is being run. I do not have registered domain since I want to test my app for start.

server {
       listen 80;
       listen [::]:80;
       root /var/www/bjrevotracking;
       index index.html index.htm;
#       server_name appone.com www.appone.com;
location / {
       try_files $uri $uri/ =404;
       }
location /api {
       proxy_pass http://localhost:5000;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection keep-alive;
       proxy_set_header Host $host;
       proxy_cache_bypass $http_upgrade;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
       }
error_log /var/www/bjrevotracking/error.log warn;
}

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi there @nosfaratus,

This sounds like a problem with Nginx, what I could suggest here is to check a few things first:

  • Make sure Nginx is up and running:
  1. sudo systemctl status nginx
  • Make sure that there are no syntax errors in your Nginx config:
  1. sudo nginx -t
  • Try specifying a server_name for your server block:
    server_name  _;
  • In case that you have a firewall, make sure that port 80 is open

Let me know how it goes! Regards, Bobby