How to run Glitch websites on different port than 8000

I know that glitch usually uses port 80, but I want to run websites on a different port like 1000 or so. Python is installed in the CLI/Terminal, so I was able to use the code:

python3 -m http.server <port>

and it would presumably run a server in python at <port>. I wasn’t, however, able to find where the files like index and such would go to to be displayed, so it just remained as empty and did not load. On closing Terminal or computer terminal is running from, the http server was just stopping and did not load the next day until the above command was written again. How do I run the website at a port then?

glitch only exposes port 3000, any attempt to listen to requests on another port will not work.

some more context for your app would help to understand the sittuation and solution. If you’re just running a static website (which it sounds like you are) then you don’t need to worry about actually running the server, glitch will do that for you as long as you don’t have a package.json, glitch.json or requirements.txt. If you’ve got some python file running e.g. flask or django, then you’ll need a requirements.txt and a start.sh containing e.g. python3 main.py. If it’a a node project it should work off the back. But if you’re trying to use port 80 or 8000 then you’ll need to change that to 3000 no matter what.

2 Likes

It is giving an error when allocating 3000 because, obviously its in use and couldnt bind socket

right, if you’re trying to run 2 different applications then you’ll probably need to run them in two different glitch apps, unless you can bundle the logic together into one process.

but again, a description of what you’re trying to do - or, even better, a link to your project - would be invaluable in trying to understand what you’re doing and whether that’s the best way of doing things.

if the default server is already occupying that port, edit the scripts.start setting in your package.json file to run your server instead

This topic was automatically closed after 180 days. New replies are no longer allowed.