# Port already in use, what to do?

**URL:** https://meta.discourse.org/t/port-already-in-use-what-to-do/27954
**Category:** Self-hosting
**Created:** [2015年四月25日 17:56 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954 "2015-04-25T17:56:10Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月25日 17:56 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/1 "2015-04-25T17:56:10Z")

</div>

Hi, just tried to setup Discourse and all went good except for launching it.  
It gives the following error:

```
starting up existing container
+ /usr/bin/docker start app
Error response from daemon: Cannot start container app: Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
FATA[0000] Error: failed to start one or more containers

```

Which suggests the port is already in use. On the system we run a web (apache, teamspeak and minecraft server.  
I am not the best with Linux and Apache, so I was wondering if anyone could help.

Thanks in advance, if you need any more information, let me know.

Regards,  
Exuraz

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年四月25日 18:02 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/2 "2015-04-25T18:02:12Z")

</div>

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247):
>
> @pfaffman edited this heavily 2022.02.24. Blame me if it’s broken. If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container. NOTE: This is for advanced admins This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working. You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will…

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月25日 19:20 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/3 "2015-04-25T19:20:50Z")

</div>

Thanks for the quick reply,

I am not sure though if I am capable of doing all of that, I am really a beginner with Linux and the stuff there seems quite tricky, especially since it has to be configured with other webservices as well (Or so it seems according to the last part of the guide, suggesting to add other services to the proxy as well.)

Anyways, will see if I can manage.

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月25日 20:32 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/4 "2015-04-25T20:32:03Z")

</div>

I managed to get it running (the container, that is) but I don’t really understand yet what port it runs on and how I can access it. [forum.mydomain.com](http://forum.mydomain.com) gives me nothing, probably because I haven’t set up DNS yet? and wouldn’t know where else it should be on. :4001 doesn’t work either but tinkering with firewall now.

Do you know what I am doing wrong?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2015年四月25日 20:44 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/5 "2015-04-25T20:44:25Z")

</div>

This error comes up often enough that I think our startup scripts should offer guidance for it. I am getting really sick of reading the “oh no, port 80 is in use” install topics.

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月25日 20:46 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/6 "2015-04-25T20:46:43Z")

</div>

Sorry, just not good with Linux to figure all of this out by myself.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2015年四月25日 20:48 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/7 "2015-04-25T20:48:32Z")

</div>

Not a problem, just pointing out that this comes up a LOT. And our scripts should offer advice when it does, automatically.

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月25日 20:50 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/8 "2015-04-25T20:50:44Z")

</div>

I understand. That’d be very useful. I think I set things up correctly now with @riking’s way - if that’s the advice you mean - it’s just that it refuses the connection when I try to connect to mydomain:4001 (All ports in that topic mentioned that so I am figuring that is the point it redirects it to?)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年四月26日 00:20 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/9 "2015-04-26T00:20:32Z")

</div>

The first post isn’t using port 4001 anymore, but rather a UNIX socket connection to get into the container. It’s supposed to get you to set up a nginx on the host that proxies to either Discourse or your other sites.

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月26日 00:36 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/10 "2015-04-26T00:36:04Z")

</div>

I followed everything in your guide except for the firewall part since I thought that was only for security and can be done later when stuff actually works, and because even in the replies there were a couple of issues with it.

I set up nginx correctly with atleast Discourse, but I still can’t acces discourse. Do I have to do anything on the DNS side to be able to connect to the Discourse subdomain?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年四月26日 00:57 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/11 "2015-04-26T00:57:01Z")

</div>

Is nginx actually running? on port 80?

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月26日 08:27 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/12 "2015-04-26T08:27:37Z")

</div>

Well to me it seems it’s not, according to these;

 ![](https://global.discourse-cdn.com/meta/original/4X/b/9/d/b9dc1daec6061204c136430bf241a4edb9b99489.png)  
 ![](https://global.discourse-cdn.com/meta/original/4X/8/4/6/84602fad3f268cd4e701c1ff77a5b5b253157076.png)  
Could it be because Apache is already listening to it?

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月26日 10:25 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/13 "2015-04-26T10:25:27Z")

</div>

So I managed to make nginx listen to port 80

 ![](https://global.discourse-cdn.com/meta/original/3X/9/f/9fa220aff93a6a2bb481b1a4e4a1d48b2adbe9ee.png)  
Apache listens to port 8080 and is redirected by nginx to [mydomain.com](http://mydomain.com)

Still, discourse doesn’t appear on [forum.mydomain.com](http://forum.mydomain.com)

Here are some of the config files:  
App.yml [https://gist.github.com/Exuraz/a9fc1f151b67837fc9ca](https://gist.github.com/Exuraz/a9fc1f151b67837fc9ca)  
nginx main site [https://gist.github.com/Exuraz/e633ec63099a9cd5e8af](https://gist.github.com/Exuraz/e633ec63099a9cd5e8af)  
nginx discourse [https://gist.github.com/Exuraz/0ec996e5b1252b6b6cfc](https://gist.github.com/Exuraz/0ec996e5b1252b6b6cfc)  
Apache main site [https://gist.github.com/Exuraz/b44bbaeebe3ab2f18b90](https://gist.github.com/Exuraz/b44bbaeebe3ab2f18b90)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年四月26日 22:11 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/14 "2015-04-26T22:11:40Z")

</div>

```plaintext
$ curl http://forum.noodlepowered.com
curl: (6) Could not resolve host: forum.noodlepowered.com

```

You don’t have DNS set up.

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月26日 22:55 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/15 "2015-04-26T22:55:40Z")

</div>

Ah okay thanks, I suppose theres instructions on that somewhere too so wil figure that out. Atleast Nginx runs properly now, thanks for the help 🙂

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年四月26日 23:05 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/16 "2015-04-26T23:05:06Z")

</div>

You’ll want to go to your DNS provider and Cloudflare (which might be the same thing) and set up `forum.` to point to the same IP address. Make sure to disable content optimizations in CloudFlare - they mess up the Discourse JS.

---

<div class="post-metadata">

### Author: ![Exuraz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/exuraz/32/116018_2.png) [@Exuraz](https://meta.discourse.org/u/Exuraz)
#### Post date: [2015年四月27日 09:24 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/17 "2015-04-27T09:24:49Z")

</div>

Alright not sure if we have cloudflare but will see if I can get things to work. Thankou very much for the help 🙂

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年四月27日 19:07 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/18 "2015-04-27T19:07:05Z")

</div>

> [@Exuraz](#):
>
> not sure if we have cloudflare

I’m pretty sure you do:

```
noodlepowered.com.	10800	IN	SOA	greg.ns.cloudflare.com. dns.cloudflare.com. 2018181667 10000 2400 604800 3600

```

(SOA = Source Of Authority or something)

---

<div class="post-metadata">

### Author: ![awfulcitizen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awfulcitizen/32/116914_2.png) [@awfulcitizen](https://meta.discourse.org/u/awfulcitizen)
#### Post date: [2015年十月19日 17:25 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/19 "2015-10-19T17:25:06Z")

</div>

> [@codinghorror](#):
>
> [https://gist.github.com/Exuraz/b44bbaeebe3ab2f18b90](https://gist.github.com/Exuraz/b44bbaeebe3ab2f18b90)

Will this ever happen?

---

<div class="post-metadata">

### Author: ![chamunks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chamunks/32/73257_2.png) [@chamunks](https://meta.discourse.org/u/chamunks)
#### Post date: [2017年五月29日 18:00 UTC](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954/20 "2017-05-29T18:00:43Z")

</div>

> [@codinghorror](#):
>
> This error comes up often enough that I think our startup scripts should offer guidance for it. I am getting really sick of reading the “oh no, port 80 is in use” install topics.

Would this be something that might happen at some point? I’m trying to get Discourse to bind to an alt port (9000?) like I recall vaguely that it used to. It seems that there’s always been some ambiguity on how to bind this to other IP’s on the host or even alternate ports.

[下一頁](https://meta.discourse.org/t/port-already-in-use-what-to-do/27954.md?page=2)
