Skip to content

Commit

Permalink
fix: actually bind to ipv4
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Jul 23, 2024
1 parent 487c93b commit 4052807
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use actix_web::{get, web, App, HttpResponse, HttpServer};
use anyhow::bail;
use std::{net::Ipv6Addr, sync::Arc};
use std::{
net::{Ipv4Addr, Ipv6Addr},
sync::Arc,
};
use tokio::{
net::TcpListener,
sync::{oneshot, Mutex},
Expand Down Expand Up @@ -54,7 +57,7 @@ impl Server {
Ok(acceptor) => acceptor,
Err(err) => {
log::info!("Failed to bind to IPv6 localhost, trying IPv4 instead: {err}");
match TcpListener::bind((Ipv6Addr::LOCALHOST, port)).await {
match TcpListener::bind((Ipv4Addr::LOCALHOST, port)).await {
Ok(acceptor) => acceptor,
Err(err) => {
log::error!("Failed to bind to either IPv6 or IPv4: {err}");
Expand Down

0 comments on commit 4052807

Please sign in to comment.