Fix for those encountering the 98: Cannot assign requested address issue
-
- Posts: 3
- Joined: Sat Jun 01, 2019 8:11 pm
- Os: CentOS 6x
- Web: apache
Fix for those encountering the 98: Cannot assign requested address issue
Previously I encountered the error [emerg] bind() to 0.0.0.0:80 failed (98: Cannot assign requested address). My nginx.conf was fine so I wasn't sure what was going on. I had almost given up, when I decided to look for the web port that Nginx was listening to. I knew the error was telling me it wouldn't bind to a port, but when I stopped Apache, it would.
Well, I can't have both Nginx and Apache on the same port, so I changed the web port for Nginx.
1. Log into the server via SSH
2. Stop iptables
3. Goto /etc/nginx/conf.d/default.conf
4. By default, the port is 80, the same as apache. Change this to something else. In my instance, I changed it to 8181.
5. Save.
6. Stop Vesta and kill any Nginx processes that are running/stalled.
7. Restart Vesta. This starts Vesta and Nginx.
8. Add the port in the firewall. If you don't and you reboot or start the firewall, you'll get locked out.
Prior:
[root@204816-4 conf.d]# service nginx stop
Redirecting to /bin/systemctl stop nginx.service
[root@204816-4 conf.d]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2019-06-01 23:03:08 EDT; 23s ago
Docs: http://nginx.org/en/docs/
Process: 99645 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
Now:
[root@204816-4 conf.d]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2019-06-01 23:04:25 EDT; 7min ago
Docs: http://nginx.org/en/docs/
Process: 99751 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 99752 (nginx)
CGroup: /system.slice/nginx.service
├─99752 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─99753 nginx: worker process
Odd that both would use the same port, and I wonder why this isn't defined differently by default.
Glad this is over with!
Well, I can't have both Nginx and Apache on the same port, so I changed the web port for Nginx.
1. Log into the server via SSH
2. Stop iptables
3. Goto /etc/nginx/conf.d/default.conf
4. By default, the port is 80, the same as apache. Change this to something else. In my instance, I changed it to 8181.
5. Save.
6. Stop Vesta and kill any Nginx processes that are running/stalled.
7. Restart Vesta. This starts Vesta and Nginx.
8. Add the port in the firewall. If you don't and you reboot or start the firewall, you'll get locked out.
Prior:
[root@204816-4 conf.d]# service nginx stop
Redirecting to /bin/systemctl stop nginx.service
[root@204816-4 conf.d]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2019-06-01 23:03:08 EDT; 23s ago
Docs: http://nginx.org/en/docs/
Process: 99645 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
Now:
[root@204816-4 conf.d]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2019-06-01 23:04:25 EDT; 7min ago
Docs: http://nginx.org/en/docs/
Process: 99751 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 99752 (nginx)
CGroup: /system.slice/nginx.service
├─99752 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─99753 nginx: worker process
Odd that both would use the same port, and I wonder why this isn't defined differently by default.
Glad this is over with!