Port already in use, what to do?

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?)

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.

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?

Is nginx actually running? on port 80?

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

Could it be because Apache is already listening to it?

So I managed to make nginx listen to port 80

Apache listens to port 8080 and is redirected by nginx to mydomain.com

Still, discourse doesn’t appear on forum.mydomain.com

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

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

You don’t have DNS set up.

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 :slight_smile:

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.

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

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)

Will this ever happen?

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.

This (port conflict) was handled in the script a while ago. Needing to proxy is a whole other deal there are #howto topics on that.

This is the guide that the script links to but I don’t want to tear down my production website just to install discourse.

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.
1 Like

Since this topic was helpful I’ll just add to it even if it’s 3 years old. I encountered the port in use problem today and am somewhat baffled by what happened. Just showing order of events in case someone else runs into it.

Background: Running Ubuntu 16.04.3 LTS (far too scared to upgrade to 18.04) and Discourse 2.3.x (not sure which, reason for that later :slight_smile: ).

Did a change (irrelevant) to app.yml and rebuilt the app.

Also noticed Ubuntu wanted to restart (didn’t check the reason) so rebooted Ubuntu as well.

And ended up with the port error problem.

Figured out Apache2 was suddenly running so I disabled it:
root@Discourse:~# sudo update-rc.d apache2 disable
insserv: warning: current start runlevel(s) (empty) of script apache2' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script apache2’ overrides LSB defaults (0 1 6).

And got the forum back up eventually as the port was now free.

What I cannot figure out is why this happened? Where did Apache2 come from?

I should have tested the forum immediately after the restart, dang. Now I don’t know whether the Discourse upgrade or the Ubuntu restart was responsible for this (I can probably find that in some log but I’m not any good with Linux anymore). Even tried to find on the forum if Discourse 2.5 installs Apache2 these days.

Good thing is, upgrading Discourse was long overdue. I’m just very reluctant to upgrade nowadays since I’ve had problems like this every second time or so in the past 5 years. Still love Discourse though…

1 Like

From your description, the best way to know if another upgrade is going to cause a problem is to upgrade three days in a row - it really should be easy enough that that is workable!

In general, expect that if it’s been a year+ since your last Discourse upgrade, you’ll need ./launcher rebuild app . I recommend visiting /admin/upgrade more frequently of course :slight_smile:

2 Likes

If you app.yml called something else you need to

  ./launcher stop irrelevant 

Or rename it and rebuild that.

2 Likes

Discourse installs nothing outside the container aside from docker as an installation prerequisite.

It’s likely Apache2 was installed after the last reboot and couldn’t take the port until you restarted the machine. Grep your bash history to check what packages have been installed by hand.

1 Like

Thanks for the ideas everyone.

I did use rebuild app. And if Discourse installs nothing extra (was thinking nginx and Apache2 would come by default because of something new)… hmmm. I certainly haven’t added Apache2 myself.

Ah. After having this DigitalOcean Ubuntu for Discourse only for years and years I actually installed Subversion in January, apparently without rebooting. That install apparently adds Apache although disabling it still leaves me with the functionality I need.

Guess I’m not so used to installs adding garbage (yes I’m sure Apache is needed for something). That more commonly happens on like, Windows or Android :smiley: .

Sorry for the trouble. Then again, this is a real use case scenario, always good to read those as a developer.

1 Like