# Difference between socket- and port-based connection to outer NGINX?

**URL:** <https://meta.discourse.org/t/difference-between-socket-and-port-based-connection-to-outer-nginx/60071>\
**Category:** Self-hosting\
**Created:** [2017年三月29日 00:09 UTC](https://meta.discourse.org/t/difference-between-socket-and-port-based-connection-to-outer-nginx/60071 "2017-03-29T00:09:05Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)\
**Post date:** [2017年三月29日 09:20 UTC](https://meta.discourse.org/t/difference-between-socket-and-port-based-connection-to-outer-nginx/60071/9 "2017-03-29T09:20:01Z")

</div>

Yes, the error is on a client machine. Okay, then I suspect the problem is with my `/etc/nginx/sites-available/default`. For the time being I set it to listen to port 81:

```
server {
        listen 81 default_server;
        listen [::]:81 default_server;
        server_name 88.99. **.** mydomain.net www.mydomain.net;

```

In my mind, this should imply that `/etc/nginx/sites-available/default` will not interfere with the settings in `discourse.conf` and indeed: if I change the defauklt server to port 80, I get the BGINX welcome page instead of ERR\_CONNECTION\_REFUSED.

So maybe my discourse.conf is simply not being included in the `nginx.conf`? That would also explain why NGINX din’t complain about the extra }… And indeed, I had my discourse.conf in the wrong path (`sites-available` instead of `sites-enabled`).

But when I fixed that, I saw the NGINX welcome page even when calling [test.mydomain.net](http://test.mydomain.net). So, for lack of other ideas, I tried starting the conainer but uit said it was already started. So I stopped and re-started it and now I’m getting 502 bad gateway.

So I did a cleanup based on [this suggestion](https://meta.discourse.org/t/502-bad-gateway-nginx-issue/44391/3) (plus a stop and restart of the container) and tada it is finally working. 🎉

So, to draw some lessons from this that might be useful for others: what puzzles me is how exactly the container interacts with the outer NGINX. As I indicated earlier, I was assuming that they are two separate entities that are merely linked in that they are sending packets back and forth between them. In other words: changes in the NGINX-configuration will not affect the container at all, as long as those packets are still sent back and forth. But now it looks like the container “fixed itself” after I fixed the outer NGINX?!?

Or maybe this is just a combination of several independent issues? In other words: if I had done a container cleanup earlier, and then fixed the outer NGINX, the result would have been the same?

---

_[View the full topic](https://meta.discourse.org/t/difference-between-socket-and-port-based-connection-to-outer-nginx/60071)._
