How to remove 8000 port from the website?

Hello! How to remoove 8000 port from my website? How to change webstudioamerica.com:8000 to webstudioamerica.com? Without 8000 is not working and with 8000 is working. And in the future I want to make more django servers, like 8001, 8002,… How to manage that and whats a problem? Thank you a lot!

<VirtualHost *:80>
ServerAdmin webstudioamerica@gmail.com
ServerName webstudioamerica.com

DocumentRoot /var/www/html/webstudioamerica/webstudio/templates

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /static /var/www/html/webstudioamerica/webstudio/static
<Directory /var/www/html/webstudioamerica/webstudio/static>
    Require all granted
</Directory>

Alias /media /var/www/html/webstudioamerica/webstudio/media
<Directory /var/www/html/webstudioamerica/webstudio/media>
    Require all granted
</Directory>

WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/www/html/webstudioamerica/webstudio/wsgi.py

<Directory /var/www/html/webstudioamerica/webstudio/wsgi.py>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

Is this a full server that you are hosting on, such that you have complete control over it? Or are you using a hosted platform such as heroku?

If it’s a full server, the first thing I’d want to look at is to see what process has control of port 8000.

Also, from what I can see, the active webserver is nginx, not apache - this configuration file isn’t doing anything. You should be looking at your nginx configuration.

1 Like

It is Amazon AWS server. Currently, i am exprerimenting with nginx and and everything is useless.

python3 16423 root 4u IPv4 148292 0t0 TCP *:8000 (LISTEN)

Find a decent resource for learning how to configure a deployment environment.

Personally, I think this blog is particularly good: How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 22.04 | DigitalOcean

1 Like

Great, I did it. Thank you very much. One more question. How much easier is it to set up hosts and other things on Heroku?

I wouldn’t know. I’ve never tried to use Heroku for a deployment. From what little I know about it, it would be too limiting for me.

1 Like

Now I have a problem with transferring the project from my local computer to the server. With PHP, it’s simple - just copy the files and that’s it. But here - I copied them, and nothing works.

It was much easier to set up without Gunicorn and sockets, just through a proxy in Nginx.

server {
listen 80;
server_name your_domain_or_ip;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /path/to/your/django/project;
}

location / {
    include proxy_params;
    proxy_pass http://127.0.0.1:8000;
}

}

KenWhitesell, do you know which one forum-CMS using this forum? It is good one…

I find out that it is Discourse, but sadly it based on ruby…

Yes, but “easier” doesn’t always mean “correct” or “best practice”.

If you’re not using gunicorn, what are you using? Uwsgi? Something else?

(Hopefully you’re not using either runserver or Werkzeug, as neither are appropriate for a production deployment.)

I agree, I think this is a fantastic package.

1 Like

What problems with runserver?

Quoting directly from the official docs for runserver

DO NOT USE THIS SERVER IN A PRODUCTION SETTING.

[ed: Emphasis added]

If the official Django docs are telling you not to do something, then I’m going to strongly recommend that you not do it.

1 Like

It is working with gunicorn, but it has problems with mp4 files Problem with deploying mp4 files in production and with admin static files. Did you solved these problems?

I use nginx to serve all static files - works great for everything. This makes it a completely different situation than the issue you’re referring to, where the poster there is trying to use WhiteNoise for this.

1 Like

So why, when I am running runserver then /static/america.mp4 is ok and when I am running gunicorn, then it is 404?

Could be any number of reasons.

  • Improper Django configuration for static files

  • Improper Nginx configuration for static files

  • Not having the file in the right directory.

  • Not having the permissions correct on the file.

(And probably a couple more possibilities that I’m not thinking of right off-hand.)

See How to deploy static files | Django documentation | Django and the pages that it links to.

(Properly handling static files in a production deployment does tend to be an issue that most people find difficult the first time. You’re not alone in this.)

1 Like