I have deployed a Flask app on Heroku and I cannot open it. In the logs, here is the error:
2022-06-25T18:36:16.177143+00:00 app[web.1]: Address already in use
2022-06-25T18:36:16.177143+00:00 app[web.1]: Port 5000 is in use by another program. Either identify and stop that program, or start the server with a different port.
2022-06
I haver changed the port severally, but same error
Solved
I removed
app.run(port="8000")
and I deployed it
Related
My Django application run well for a while, then I got 502 Bad Gateway, after a few hours, I am unable to ping the domain and use SSH to connect my server(from Amazon Lightsail). My other application served by ngnix was also not available then. While if I didn't start the Django application, ther application served by ngnix would run steadily. So I guess it is the error of my Django application crashed ngnix and the server.
After rebooting the server for serveral times, the server seems recovered then I can ping the domain and use SSH to connect the server. But after a while, the same problem would occurs again. I wonder how to fix the problem.
Some diagnostic information since the start of the Django application to the end of the Nginx server provided below.
The RAM usage is high during the process.
The uwsgi log. https://bpa.st/FP7Q
The Nginx error log. https://bpa.st/35EQ
I have a Flask app running with docker and uwsgi on AWS. I have some endpoints and when I do a POST to one of them, using Postman or Curl, I see on the logs the response status code 412, but on Postman or Curl it shows 502.
I tried to run the Flask app locally without docker but using uwsgi, and it runs as expected.
I need to have a 412 response to know how to handle this status code.
If the flask app works as expected on your local machine, it might have something to do with how the port routing is setup for your container.
In addition to the port your flask application is receiving requests on, there is a Docker container that it lives inside that also has its own ports. The first is an external set of ports that need to be exposed to receive requests, and there's another set of internal ports that can be linked to external ports and used by your application.
The long explanation is available in this answer here, but the TLDR is:
Running your container with docker run -it --expose 8008 -p 8008:8008 myContainer
will allow for an externally exposed port with --expose EXTERNALPORT and will bind the internal container port to the external container port with -p INTERNALPORT:EXTERNALPORT.
Lastly, when running your flask service, you'll need to make sure that its port lines up with the internally exposed container port. An example using the same port we listed before would be:
flask run --host=0.0.0.0 --port=8008
I am following these instructions to deploy a Django app on Google App Engine:
https://cloud.google.com/python/django/appengine
I have got as far as downloading the proxy .exe file (I am on a Windows machine) and connecting to it:
2019/01/08 16:14:08 Listening on 127.0.0.1:3306 for
[INSTANCE-NAME] 2019/01/08 16:14:08
Ready for new connections
When I try and create the Django migrations by running python manage.py createmigrations I see the connection received by the proxy file:
2019/01/08 16:15:06 New connection for
"[INSTANCE-NAME]"
However, after a couple of seconds pause I get this error:
2019/01/08 16:15:28 couldn't connect to
"[INSTANCE-NAME]": dial tcp
35.205.185.133:3307: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have tried disabling my local firewall in case this was causing any issues, but the result is the same. I've also checked the username, password and Cloud SQL instance name, they are all correct.
What could be causing this error?
A simple django chatapp with swampdragon runs perfectly locally. But when I try to deploy it on heroku it shows "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch" in the log. In the proc file I added "web: python server.py". which runs in the port 9999 locally. But how do I handle the port 9999 with heroku?
See this question:
Setting the port for node.js server on Heroku
You can't specify which port you want to use on Heroku.
Heroku sets it 'automatically' so you should read what the PORT variable is in the environment then use that.
heroku config:get PORT
references: https://devcenter.heroku.com/articles/config-vars
I just begun using Flask and tried to run the hello_world example (hello.py)
The point is that I run the server through ssh on a remote machine and I want to browse it from my local machine so I used
app.run(host='0.0.0.0'),
However when I browse on chrome I put let's say http: //RemoteMachineIP:5000/ I got:
Oops! Google Chrome could not connect to RemoteMachineIP:5000
The remote machine has multiple ethernet IP addresses so I tried them (as http: //RemoteMachineIP:5000/) and I am always getting the same error.
I have also tried using app.run(host='LocalMachineIP') in hello.py but I got this error Flask [Errno 99] Cannot assign requested address.
Am I missing something ?
If you can run the server but the browser won't see it, it is a firewall problem.
If you can't assign the ip port, probably there is a PID already using the port, so you should try
lsof -i :5000
Then
kill -9 [PID From the lsof]