# Getting errors while installing nginx

**URL:** <https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728>\
**Category:** Troubleshooting\
**Created:** [November 13, 2020, 3:23am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728 "2020-11-13T03:23:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 13, 2020, 3:23am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/1 "2020-11-13T03:23:37Z")

</div>

While installing nginx, I am getting some few errors, these are the errors  
-"/var/log/nginx/error.log" failed (13: Permission denied)

- “etc/nginx/sites/-enabled/letsecrypt” failed (21: is a directory)

- configuration file /etc/nginx/nginx.conf test failed

curl [http://localhost](http://localhost)  
curl (7) Failed to connect to localhost port 80:Connection refused.

systemctl status nginx  
Active: failed

Please help. Really need help.  
Thanks

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 13, 2020, 1:08pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/2 "2020-11-13T13:08:03Z")

</div>

Hello @pooh_bear, I’m sorry to hear you’re having issues, with a bit of additional information I believe I can help you fix this.

So that I can better understand what the issue may be, would you be willing to provide the following?

- OS version & architecture
- Nginx configuration file contents
- output of running the command (If on Linux) `ls -alh /var/log/`
- Further details about any firewall that you may have running, and if running, what the rules are for the firewall (Ex. block all requests on port 21, allow all requests on 80, etc.)

Thanks!

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 13, 2020, 4:18pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/3 "2020-11-13T16:18:30Z")

</div>

Thank you so much!!!

I am working on windows 10.

**To install NGINX on Ubuntu Server:**  
curl [http://localhost](http://localhost)  
“/etc/nginx/sites-enabled/letsencrypt” failed

I don’t get any output on ls -alh/var/log/

ERR connection refused.

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 14, 2020, 3:34am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/4 "2020-11-14T03:34:27Z")

</div>

I’m somewhat confused honestly. It seems to me that you are working with software that is meant for linux operating systems only, on a windows 10 environment. Is this correct?

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 14, 2020, 4:10am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/5 "2020-11-14T04:10:26Z")

</div>

> [@XxLilBoPeepsxX](#):
>
> Nginx configuration file contents

Yes, I am working on windows. Btw, `ls -alh /var/log/` on this I am getting some lists.

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 15, 2020, 3:35am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/6 "2020-11-15T03:35:06Z")

</div>

Ahh yes, the `alh` flag will list all files, in a list, in human-readable format, including hidden files. What are the files that you are getting as output? These should be the error and runtime log files, which will be very helpful to see the contents of, to further diagnose the issues your having and get it resolved.

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 16, 2020, 3:47pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/7 "2020-11-16T15:47:42Z")

</div>

On “postgresql” is kinda dark highlight…Could this be an error???

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 17, 2020, 8:06pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/8 "2020-11-17T20:06:12Z")

</div>

What specifically is highlighted? Is it files of different types highlighted with different colors?  
It might be helpful if you could maybe provide a screenshot of what you see on your end to help us understand a bit better 🙂

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 18, 2020, 2:57am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/10 "2020-11-18T02:57:27Z")

</div>

Thank you so much! That makes things so much clearer! So, just for clarification for your sake, the red-colored files are .gz files, which are essentially the Linux version of a .zip file; they each have multiple older log files in them. In the `/var/log/nginx/` folder, you should have the logs from the server, and specifically, one of them should be called `error.log` or something along those lines, can you copy and paste the contents of that file here? That will show us exactly what the server itself is saying is wrong with itself, and give us information on what needs to be fixed.

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 18, 2020, 4:35am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/12 "2020-11-18T04:35:12Z")

</div>

well, the contents of the log, yes. If you run the command `cat /var/log/nginx/error.log` and paste that output here, that will provide information, a lot of very useful information.

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 18, 2020, 3:25pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/13 "2020-11-18T15:25:03Z")

</div>

Ok. This is what I got.

 ![2020-11-18 (2)_LI](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/3/34503387252df61aa38219fa1e0947e173df59d1.jpeg)

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 19, 2020, 2:22am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/14 "2020-11-19T02:22:31Z")

</div>

Well crap. I guess you must not even have been able to get far enough in the startup process to generate an error log, or because of the permissions issues referenced in the original post that started this thread. That sucks 😆 Don’t worry though, we’ll get this figured out!

Based on your original post, I think that there are a few things that need to be checked.

> [@pooh\_bear](#):
>
> curl (7) Failed to connect to localhost port 80:Connection refused

Could you run the command `ufw allow 80` and `ufw allow http` to make sure that your firewall is allowing port 80 (the default HTTP protocol port) to transmit data.

> [@pooh\_bear](#):
>
> configuration file /etc/nginx/nginx.conf test failed

This leads me to think that there may have been an error made in the configuration of the Nginx server configuration file. I’d like to personally take a look, if your willing to share the contents of the file with me. You can retrieve the contents by using the following command: `cat /etc/nginx/nginx.conf` and copy/pasting the resulting output here.

> [@pooh\_bear](#):
>
> -“/var/log/nginx/error.log” failed (13: Permission denied)

I’d like to check the permissions of the directories leading up to the `/var/log/nginx/error.log` file, and then the permissions of the `error.log` file itself. We can do this by running the following commands:

- Check the permissions of the folder `/var/` with the command `ls -alh /`  
(we need to see the folder `var`’s own permissions, which is why we have to start a folder back, as we will need to do for each of the following. Don’t worry about going a folder back, the commands I’m providing here take care of that for you 🙂
- Check the permissions of the folder `/var/log/` with the command `ls -alh /var/` this will show us the contents of the folder `/var/ ` including the folder `/log/`.
- Check the permissions of the folder `/var/log/nginx/` with the command `ls -alh /var/log/`  
This will allow us to see the folder `nginx`’s permissions in the file system.
- Finally, the error logs themselves, which can be done with the command `ls -alh /var/log/nginx/`.

As a reference, I have included a screenshot of my own web server in which I ran the command `ls -alh /var/log/nginx/` to provide a sample of what the expected output should look like, seen below.

![image](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/e/e22d432cfa2625ff6e018686ea5e8e048b15dd01.png)

As a bit of an explanation of the output information that you will be getting with the command `ls -alh [filepath]`, I wanted to include the following. If your not interested or you already know this, by all means feel no obligation to read any further, If nothing else it’ll be a reference for other forum users.

Let us use the example from the screenshot I provided, the line  
`-rw-r----- 1 www-data adm 0 Sep 15 02:25 access.log`

This section containing `-rw-r-----` is telling us the actual permissions of the file itself, where `r` stands for read permissions, `w` stands for write permissions, and (although this file doesn’t have this permission, so you cannot see it) `e` stands for execution permissions, or in other words, permission to run the program.

The number `1` following the previous represents the number of objects contained within the file, which, because there are no folders located within the text file, is 1, for itself.

Following the `1` is ` www-data adm` which tells the human the file’s owner and group assignment within the system. _This is very important_. If the group and file owner is incorrectly set, this can restrict certain crucial system functions from being able to access or open the file, potentially resulting in the error permission denied message such as the one found in your initial post.

Following the system group and owner is the file size, converted from plain bytes into a human-readable format with the flag `-h` in the command `ls`. Because I use the Apache webserver for my Mattermost instance, and do not run Nginx except as a backup, my error.log file has a size of `0`, meaning that it is an empty file.

Finally, after the file size, you have the date and time that the file was last modified, and then the name of the file itself!

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 19, 2020, 1:28pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/16 "2020-11-19T13:28:27Z")

</div>

I think I finally understand what may be causing a big issue. I’m guessing that there is a folder called `letsencrypt` if you were to change directories to `/egc/nginx/sites-enabled/` and run the command `ls`? If yes, this is the first issue that needs to be remediated, as only individual website _configuration_ files ending in `.conf` should be in the folder `/etc/nginx/sites-enabled/`, and no other folders should be in it. Because Nginx parses all files in the `/etc/nginx/sites-enabled/` folder to load each website’s configuration file when it starts, and there is a directory in this folder, this would be (at least one) of the reasons that your server isn’t starting.

Can I ask why the `letsencrypt` folder is located in the `/etc/nginx/sites-enabled/` folder?

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 19, 2020, 1:32pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/17 "2020-11-19T13:32:45Z")

</div>

As a follow up, to move the `letsencrypt` folder to the proper location, use the `mv` command to move the folder to the correct location. You can do this with this command:  
`mv /etc/nginx/sites-enabled/letsencrypt/ /etc/letsencrypt/`  
This command will move the folder to the location `/etc/letsencrypt` which is the standard location.

Once you have done this, I suggest taking a look at the example Nginx configuration file for Mattermost, which you can find at [https://docs.mattermost.com/install/config-proxy-nginx.html](https://docs.mattermost.com/install/config-proxy-nginx.html), and get setup with a few small changes to the template provided on the documentation website, linked above.

To see if it has worked, after doing the above, run the command `sudo systemctl restart nginx` and if it doesn’t work, please provide the output of `sudo systemctl status nginx` so we can additionally troubleshoot!

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 19, 2020, 11:47pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/20 "2020-11-19T23:47:07Z")

</div>

I Don’t know how that happen, Can you help how to solve that???

Thanks

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 20, 2020, 3:31am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/21 "2020-11-20T03:31:30Z")

</div>

Yes I can! So, what the `mv` command is, is a Linux command utility to _move_ a file or folder to another location.

The required arguments are as follows:  
`mv /path/to/file/or/folder/ /location/to/move/foler/to`

In your command, you only had `mv /path/to/file/or/folder/ `  
To fix this, simply add `/etc/letsencrypt/` to the command, to form a complete command like this:  
`mv /etc/nginx/sites-enabled/letsencrypt/ /etc/letsencrypt/`

I hope that helps you!

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 20, 2020, 5:18am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/23 "2020-11-20T05:18:24Z")

</div>

My apologies, I use my linux servers as the root user so I forget that non-root users have to use sudo, it should work as  
`sudo mv /etc/nginx/sites-enabled/letsencrypt/ /etc/letsencrypt/`

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 20, 2020, 11:44pm UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/24 "2020-11-20T23:44:08Z")

</div>

Oh my god!! It worked, 🙂

Thank you so much!!!

---

<div class="post-metadata">

**Author:** ![XxLilBoPeepsxX](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/xxlilbopeepsxx/32/4993_2.png) [@XxLilBoPeepsxX](https://forum.mattermost.com/u/XxLilBoPeepsxX)\
**Post date:** [November 21, 2020, 1:43am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/25 "2020-11-21T01:43:02Z")

</div>

That’s great, I’m so excited to hear that!! 😀 Is everything functioning as expected now?

---

<div class="post-metadata">

**Author:** ![pooh\_bear](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@pooh\_bear](https://forum.mattermost.com/u/pooh_bear)\
**Post date:** [November 21, 2020, 2:18am UTC](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728/26 "2020-11-21T02:18:58Z")

</div>

Yes. It is working perfectly fine.  
Thanks.

[Next page](https://forum.mattermost.com/t/getting-errors-while-installing-nginx/10728.md?page=2)
