0

I am a beginner in web developement, trying to deploy my flask app in oracle cloud with ubuntu 18.04, nginx, uwsgi and flask.

nginx config is default.

myapp.config for server is:

server {
    listen 80;
    listen  [::]:80;
    server_name 152.67.8.6 stag.fick.in www.stag.fick.in;

    location / {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:5000;
            # unix:/home/ubuntu/FickStaging/fick_backend/fick/fick.sock;
    }
}

Now I am trying local IP but I have tried with socket(commented the .sock path) file got the same result.

myapp.ini is:

[uwsgi]
module = wsgi:application

master = true
processes = 5

socket = 127.0.0.1:5000
#unix:/FickStaging/fick_backend/fick/fick.sock
chmod-socket = 666 #660
vacuum = true

die-on-term = true

Here I am trying anything, whatever I come across from last 4 days tried to use still unable to connect.

wsgi.py is:

from app import app as application

if __name__ == "__main__":
     application.run()

I am able to access the app with ip address using wsgi file with bellow command:

uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi

but unable to access once I am using the app.ini file with command also with service.

myapp service is:

[Unit]
Description="uWSGI server instance for fick"
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/FickStaging/fick_backend/fick
Environment=FLASK_ENV=test
ExecStart=/home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.ini

[Install]
WantedBy=multi-user.target

Please consider the myapp.service status:

fick_staging.service - "uWSGI server instance for fick"
Loaded: loaded (/etc/systemd/system/fick_staging.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-07-24 05:19:40 UTC; 25min ago
Main PID: 32645 (uwsgi)
Tasks: 6 (limit: 1120)
CGroup: /system.slice/fick_staging.service
       ├─32645 /home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.
       ├─32679 /home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.
       ├─32680 /home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.
       ├─32681 /home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.
       ├─32682 /home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.
       └─32683 /home/ubuntu/.local/bin/uwsgi --ini /home/ubuntu/FickStaging/fick_backend/fick/app.

 Jul 24 05:19:40 ubuntu uwsgi[32645]: mapped 437424 bytes (427 KB) for 5 cores
 Jul 24 05:19:40 ubuntu uwsgi[32645]: *** Operational MODE: preforking ***
 Jul 24 05:19:41 ubuntu uwsgi[32645]: WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x55
 Jul 24 05:19:41 ubuntu uwsgi[32645]: *** uWSGI is running in multiple interpreter mode ***
 Jul 24 05:19:41 ubuntu uwsgi[32645]: spawned uWSGI master process (pid: 32645)
 Jul 24 05:19:41 ubuntu uwsgi[32645]: spawned uWSGI worker 1 (pid: 32679, cores: 1)
 Jul 24 05:19:41 ubuntu uwsgi[32645]: spawned uWSGI worker 2 (pid: 32680, cores: 1)
 Jul 24 05:19:41 ubuntu uwsgi[32645]: spawned uWSGI worker 3 (pid: 32681, cores: 1)
 Jul 24 05:19:41 ubuntu uwsgi[32645]: spawned uWSGI worker 4 (pid: 32682, cores: 1)
 Jul 24 05:19:41 ubuntu uwsgi[32645]: spawned uWSGI worker 5 (pid: 32683, cores: 1)

nginx service status is:

nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
       └─override.conf
Active: active (running) since Thu 2020-07-23 20:17:51 UTC; 9h ago
 Docs: man:nginx(8)
Process: 27158 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, statu
Process: 27260 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Process: 27247 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 27234 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 27248 (nginx)
Tasks: 3 (limit: 1120)
CGroup: /system.slice/nginx.service
       ├─27248 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
       ├─27254 nginx: worker process
       └─27255 nginx: worker process

Jul 23 20:17:51 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 23 20:17:51 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.

I hope both the service are running fine. I am struggling with this from last four days, checked lots of blogs and tutorials with almost same details but still unable to connect my app through public IP or domain.

Please let me know if I can provide any other details. Any help is highly appriciated, thank you all in advance :)

2
0

You should fix this typo in your ini file:

socket = 127.0.0.0:5000

The address should have been 127.0.0.1.

1
  • Thank you for noticing the mistake but after fixing it still unable to connect. – Biswajit Jul 25 '20 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.