Nginx error after ip change

I did ip change in hestia many time before with no issue. But this time even I am not sure if it is related to ip change, two asp.net sites throws 500 error.
And in logs
nginx connect() failed (111: Connection refused) while connecting to upstream, client:

If I roll back to ip backup with older ip, they run fine.

I am stucked. Any hero to help?

The error message would suggest that you’re running nginx as a proxy in front of Apache, and that apache has not started somehow. What info do these commands give you?

 journalctl -e -u apache2
 systemctl status apache2

No apache is running and no error

root@sunucu:~# systemctl status apache2
â—Ź apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-10-25 12:35:05 +03; 20h ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 447 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 681 (apache2)
    Tasks: 56 (limit: 4915)
   Memory: 31.9M
   CGroup: /system.slice/apache2.service
           ├─681 /usr/sbin/apache2 -k start
           ├─682 /usr/sbin/apache2 -k start
           ├─684 /usr/sbin/apache2 -k start
           └─685 /usr/sbin/apache2 -k start

Oct 25 12:35:04 sunucu.grandnode.tk systemd[1]: Starting The Apache HTTP Server...
Oct 25 12:35:05 sunucu.grandnode.tk systemd[1]: Started The Apache HTTP Server.

I am totally stucked for two days. I can give you ssh if you want to check. There are two asp.net core sites. One with ports 5000,5001 and 2nd 5002,5003
And they were just running fine before ip change.

Are ip adresses in the config file hard coded

No, nginx directives are:

location / {
proxy_pass http://127.0.0.1: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;
}

And for ssl:

location / {
proxy_pass https://127.0.0.1:5001;
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;
}

Do the services that run on port 5000 still run

Yes both web sites services are running:
Active: active (running)

OK, the apache thing was a false trail, so we can ignore that. You didn’t mention you’d written your own templates which were connecting to different proxies on ports 5000 and 5001.
So what nginx is saying is basically it can’t connect to the server running on http://127.0.0.1:5000 and/or https://127.0.0.1:5001

If you’re on the command line, do you get some output when you try to connect with curl eg.
curl -I http://127.0.0.1:5000/
This should just show you the headers.

Also, what output do you get from
ss -tln
This should show listening TCP sockets on your machine.

I do not think it is apache related.

root@sunucu:~# curl -I http://127.0.0.1:5000
HTTP/1.1 500 Internal Server Error
Date: Tue, 26 Oct 2021 07:45:59 GMT
Server: Kestrel
Content-Length: 0

And ss -tln

127.0.0.1:5000
127.0.0.1:5001
*:5002
*:5003

The service running on port 5000 is causing the issue. Don’t know what servers is running on but it might make sense to start debugging there.

No definitely not apache related. So you can’t connect to the asp app’s server with curl … that tells me that nginx is telling the truth, and the problem lies upstream i.e. with your app’s kestrel server.
the 127.0.0.1:5000 in the ss output confirms the URL you’re trying to connect to is OK.

So I’d be looking in your asp app / kestrel logs for the answers …

2 Likes

I can not believe it is mongodb releated. I had an incorrect setting in there. Once it is fixed then all fine.
Nginx logs of course could not tell about it. Next time I will first check web app logs :slight_smile:

Thanks guys.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.