错误:bind(): Cannot assign requested address [core/socket.c line 7
【摘要】 uwsgi 部署时踩过的坑
安装uwsgi :
(iotproenv) [root@hy-iot xuanyuaniotpro]# pip install uwsgi Collecting uwsgi Downloading uWSGI-2.0.19.1.tar.gz (803 kB) |████████████████████████████████| 803 kB 3.5 MB/s Using legacy 'setup.py install' for uwsgi, since package 'wheel' is not installed. Installing collected packages: uwsgi Running setup.py install for uwsgi ... done Successfully installed uwsgi-2.0.19.1 (iotproenv) [root@hy-iot xuanyuaniotpro]#
使用uwsgi启动django项目是异常报错:
(iotproenv) [root-yuchuan@hy-iot xuanyuaniotpro]$ uwsgi --http 52.175.153.121:8080 --file xuanyuaniotpro/wsgi.py --static-map=/static=static [uwsgi-static] added mapping for /static => static *** Starting uWSGI 2.0.19.1 (64bit) on [Thu Aug 27 14:33:48 2020] *** compiled with version: 8.3.1 20191121 (Red Hat 8.3.1-5) on 27 August 2020 14:31:25 os: Linux-4.18.0-193.6.3.el8_2.x86_64 #1 SMP Wed Jun 10 11:09:32 UTC 2020 nodename: hy-iot machine: x86_64 clock source: unix detected number of CPU cores: 1 current working directory: /home/root-yuchuan/project/xuanyuaniotpro detected binary path: /home/root-yuchuan/bin/iotproenv/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 7459 your memory page size is 4096 bytes detected max file descriptor number: 1024 building mime-types dictionary from file /etc/mime.types...1183 entry found lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) bind(): Cannot assign requested address [core/socket.c line 769]
uwsgi的日志如上图,bind(): Cannot assign requested address [core/socket.c line 769]这个是报错了,也不写error提示,花了好长时间才发现这里出错。翻译为无法分配请求的地址,但是用netstat命令看,端口没被占用啊,又花了好长时间,发现是华为云的网路问题。
uwsgi配置里的socket这里不能写127.0.0.1,要写华为的内网。就这里改一下,就可以了。
(iotproenv) [root-yuchuan@hy-iot xuanyuaniotpro]$ ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.0.5 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::20d:3aff:fe41:6c34 prefixlen 64 scopeid 0x20<link> ether 00:0d:3a:41:6c:34 txqueuelen 1000 (Ethernet) RX packets 7152163 bytes 3533038964 (3.2 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 7344248 bytes 1585544415 (1.4 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 3141 bytes 7434034 (7.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3141 bytes 7434034 (7.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
(iotproenv) [root-yuchuan@hy-iot xuanyuaniotpro]$ uwsgi --http 10.0.0.5:8080 --file xuanyuaniotpro/wsgi.py --static-map=/static=static [uwsgi-static] added mapping for /static => static *** Starting uWSGI 2.0.19.1 (64bit) on [Thu Aug 27 14:48:37 2020] *** compiled with version: 8.3.1 20191121 (Red Hat 8.3.1-5) on 27 August 2020 14:31:25 os: Linux-4.18.0-193.6.3.el8_2.x86_64 #1 SMP Wed Jun 10 11:09:32 UTC 2020 nodename: hy-iot machine: x86_64 clock source: unix detected number of CPU cores: 1 current working directory: /home/root-yuchuan/project/xuanyuaniotpro detected binary path: /home/root-yuchuan/bin/iotproenv/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 7459 your memory page size is 4096 bytes detected max file descriptor number: 1024 building mime-types dictionary from file /etc/mime.types...1183 entry found lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on 10.0.0.5:8080 fd 6 spawned uWSGI http 1 (pid: 438340) uwsgi socket 0 bound to TCP address 127.0.0.1:38249 (port auto-assigned) fd 5 Python version: 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0xa2da70 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 72904 bytes (71 KB) for 1 cores *** Operational MODE: single process *** WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xa2da70 pid: 438339 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI worker 1 (and the only) (pid: 438339, cores: 1) [pid: 438339|app: 0|req: 1/1] 129.253.180.122 () {38 vars in 696 bytes} [Thu Aug 27 14:49:18 2020] GET / => generated 74 bytes in 11 msecs (HTTP/1.1 404) 3 headers in 100 bytes (1 switches on core 0) [pid: 438339|app: 0|req: 2/2] 129.253.180.122 () {36 vars in 688 bytes} [Thu Aug 27 14:49:37 2020] GET /user_list => generated 0 bytes in 0 msecs (HTTP/1.1 301) 3 headers in 116 bytes (1 switches on core 0)
nginx这里配公网ip。
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)