# NGINX fails to start

**URL:** https://meta.discourse.org/t/nginx-fails-to-start/298533
**Category:** Self-hosting
**Created:** [March 8, 2024, 2:43pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533 "2024-03-08T14:43:22Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 8, 2024, 2:43pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/1 "2024-03-08T14:43:22Z")

</div>

Hi, everybody!

I’m trying to install discourse on a subdomain.

My main domain is running wordpress, which was built using docker-compose.

The subdomain and the domain are using the same VPS server.

For the installation I followed this guide: [https://meta.discourse.org/t/run-other-websites-on-the-same-machine-as-discourse/17247](https://meta.discourse.org/t/run-other-websites-on-the-same-machine-as-discourse/17247)

Unfortunately, NGIX cannot be started. When I run the systemctl status nginx command, the following message appears:

```plaintext
× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2024-03-08 07:06:36 CST; 1h 14min ago
       Docs: man:nginx(8)
    Process: 27329 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 27330 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 42ms

Mar 08 07:06:33 vmi1695712.contaboserver.net systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 08 07:06:33 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:34 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:34 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:35 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:35 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:36 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] still could not bind()
Mar 08 07:06:36 vmi1695712.contaboserver.net systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Mar 08 07:06:36 vmi1695712.contaboserver.net systemd[1]: nginx.service: Failed with result 'exit-code'.
Mar 08 07:06:36 vmi1695712.contaboserver.net systemd[1]: Failed to start A high performance web server and a reverse proxy server.

```

My site file for Discourse:

```plaintext
# Default server configuration
#
server {
        # listen 80 default_server;
        # listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name forum.ictsharks.com;

        location / {
                proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        #location ~ \.php$ {
        # include snippets/fastcgi-php.conf;
        #
        # # With php-fpm (or other unix sockets):
        # fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        # # With php-cgi (or other tcp sockets):
        # fastcgi_pass 127.0.0.1:9000;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        # deny all;
        #}
}

```

I’ve checked it several times, but I can’t figure out where the error is.

Sorry, I’m a beginner with Linux / NGINX / Docker things. Any advice would be appreciated. Thank you.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 8, 2024, 3:51pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/2 "2024-03-08T15:51:13Z")

</div>

> [@Deenius](#):
>
> `bind() to 0.0.0.0:80 failed`

Is there a different webserver on that machine that is hogging port 80?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 8, 2024, 3:54pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/3 "2024-03-08T15:54:39Z")

</div>

Did you change the ports in the `app.yml` so that Discourse isn’t trying to use the ports that NGINX wants?

> [@Deenius](#):
>
> Sorry, I’m a beginner with Linux / NGINX / Docker things. Any advice would be appreciated. Thank you.

This is an advanced setup that requires understanding of DNS, https and certificates, nginx, reverse proxies, docker, and routing.

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 8, 2024, 4:08pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/4 "2024-03-08T16:08:53Z")

</div>

As I mentioned, wordpress is running on the main domain.

If I understood correctly, the other NGIX works in the container together with wordpress.

I followed this tutorial: [How To Install WordPress With Docker Compose | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-docker-compose)

If I run the netstat -tulnp command, this is what I get:

```plaintext
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 419/systemd-resolve
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1192/docker-proxy
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 463/sshd: /usr/sbin
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1179/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 463/sshd: /usr/sbin
udp 0 0 127.0.0.53:53 0.0.0.0:* 419/systemd-resolve

```

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 8, 2024, 4:18pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/5 "2024-03-08T16:18:53Z")

</div>

The instructions suggest commenting them, so I did:

```plaintext
## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  # - "80:80" # http
  # - "443:443" # https

```

I understand DNS records, https and certificates. Only the rest is new to me.

Don’t worry, I know how to google and I’m a fast learner 😉

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 8, 2024, 5:25pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/6 "2024-03-08T17:25:13Z")

</div>

> [@Deenius](#):
>
> As I mentioned, wordpress is running on the main domain.

Before you started this, was it behind a working NGINX reverse proxy that you’re adding Discourse to?

Or if Apache/WordPress was running before, that’s what’s got port 80?

Oh, it looks like `docker-proxy` has port 80, so maybe you had your WordPress behind docker-proxy?

Maybe `docker ps` to see if you can see what docker

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 8, 2024, 5:42pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/7 "2024-03-08T17:42:42Z")

</div>

As I stated, I believe the other NGIX (the one for wordpress) works in a container together with MySQL, and Wordpress.

This is what I get by running docker ps command:

```plaintext
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ca4cbec2c88 local_discourse/app "/sbin/boot" 51 minutes ago Up 15 minutes app
4a3ebdd9f5b5 nginx:1.15.12-alpine "nginx -g 'daemon of…" 20 hours ago Up 15 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp webserver
42c4211a2fb6 wordpress:5.1.1-fpm-alpine "docker-entrypoint.s…" 2 days ago Up 15 minutes 9000/tcp wordpress
5b588a7435ad mysql:8.0 "docker-entrypoint.s…" 2 days ago Up 15 minutes 3306/tcp, 33060/tcp db

```

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 8, 2024, 5:53pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/8 "2024-03-08T17:53:34Z")

</div>

That would be why the external nginx cannot boot, as the ports are taken by the internal one. You probably need to shut that container down and transfer it’s config for Wordpress to the outer nginx layer.

Also, those are separate containers, the nginx is separate from MySQL and WordPress.

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 8, 2024, 6:28pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/9 "2024-03-08T18:28:15Z")

</div>

I shut down the webserver (NGIX container) and tried to start the external NGIX. Still not working.

> [@Firepup650](#):
>
> Also, those are separate containers, the nginx is separate from MySQL and WordPress.

You’re right. It’s my fault. I thought all the apps mentioned were in one container.

One container = one application/program 😉

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 8, 2024, 7:11pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/10 "2024-03-08T19:11:58Z")

</div>

> [@Deenius](#):
>
> tried to start the external NGIX. Still not working.

What’s `docker ps` and `netstat -tulnp` look like now?

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 8, 2024, 7:17pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/11 "2024-03-08T19:17:01Z")

</div>

```plaintext
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ca4cbec2c88 local_discourse/app "/sbin/boot" 3 hours ago Up 2 hours app
42c4211a2fb6 wordpress:5.1.1-fpm-alpine "docker-entrypoint.s…" 2 days ago Up 2 hours 9000/tcp wordpress
5b588a7435ad mysql:8.0 "docker-entrypoint.s…" 2 days ago Up 2 hours 3306/tcp, 33060/tcp db

```

```plaintext
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 418/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 462/sshd: /usr/sbin
tcp6 0 0 :::22 :::* LISTEN 462/sshd: /usr/sbin
udp 0 0 127.0.0.53:53 0.0.0.0:* 418/systemd-resolve

```

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 8, 2024, 7:20pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/12 "2024-03-08T19:20:29Z")

</div>

Not much else I can do here, does nginx look like it’s still doing the same thing, or has the error changed at all?

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 8, 2024, 8:06pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/13 "2024-03-08T20:06:06Z")

</div>

> [@Deenius](#):
>
> The instructions suggest commenting them

This should be done _in conjunction_ with adding the `web.socketed.template.yml` template, did you do that?

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 9, 2024, 6:26am UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/14 "2024-03-09T06:26:30Z")

</div>

Yes, I did.

I tried uninstalling and reinstalling NGIX and deleted the configuration file. However, the problem persists.

I will try to look for the NGIX errors listed and see what I find.

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 9, 2024, 7:16am UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/15 "2024-03-09T07:16:33Z")

</div>

I solved the NGIX issue! 😀

In the /etc/nginx/sites-enabled/ folder there was some nonsense “ysystemctl status nginx” file. I deleted it.

Now, NGIX is working 💪

I’ll follow the [riking](https://meta.discourse.org/u/riking)’s instructions and let you know how it turns out.

---

<div class="post-metadata">

### Author: ![Deenius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deenius/32/369129_2.png) [@Deenius](https://meta.discourse.org/u/Deenius)
#### Post date: [March 9, 2024, 10:09am UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/16 "2024-03-09T10:09:52Z")

</div>

Ok, my discourse forum is up and running!

Unfortunately, the instructions don’t mention how to modify the settings for NGINX, which is running the website/WordPress.

It only says this: Make other NGINX “sites”, then link and enable them, as in the last step above.

I would really appreciate any tips on how to achieve this.

I installed wordpress according to this guide: [How To Install WordPress With Docker Compose](https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-docker-compose)

Besides that, can you please confirm or deny my conclusions?

1. NGINX (the one not in the container) is used as a reverse proxy.
2. NGINX (the one not in the container) is referred to as “outer NGIX”.
3. NGINX (the one not in the container) uses unix sockets instead of TCP ports for communication in the current setup.
4. Discourse is a standalone application and therefore does not need to install its own NGIX webserver.

I apologize if I’m trying to verify obvious things. I just want to be 100% clear.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 9, 2024, 12:05pm UTC](https://meta.discourse.org/t/nginx-fails-to-start/298533/17 "2024-03-09T12:05:10Z")

</div>

That’s pretty much it.

The discourse container includes nginx, rails, postgres and redis.
