diff --git a/frappe/app.py b/frappe/app.py index b19881c6e0..8a263af1f0 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -408,7 +408,7 @@ def serve( application = application_with_statics() application.debug = True - application.config = {"SERVER_NAME": "localhost:8000"} + application.config = {"SERVER_NAME": "127.0.0.1:8000"} log = logging.getLogger("werkzeug") log.propagate = False diff --git a/frappe/commands/site.py b/frappe/commands/site.py index defc735ddd..263c5438bf 100644 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -1169,7 +1169,7 @@ def start_ngrok(context, bind_tls, use_default_authtoken): port = frappe.conf.http_port or frappe.conf.webserver_port tunnel = ngrok.connect(addr=str(port), host_header=site, bind_tls=bind_tls) print(f"Public URL: {tunnel.public_url}") - print("Inspect logs at http://localhost:4040") + print("Inspect logs at http://127.0.0.1:4040") ngrok_process = ngrok.get_ngrok_process() try: diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index 149e42dd80..6a8c17c964 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -152,7 +152,7 @@ class EmailAccount(Document): self.password = None if not frappe.local.flags.in_install and not self.awaiting_password: - if validate_oauth or self.password or self.smtp_server in ("127.0.0.1", "localhost"): + if validate_oauth or self.password or self.smtp_server in ("127.0.0.1", "127.0.0.1"): if self.enable_incoming: self.get_incoming_server() self.no_failed = 0 diff --git a/frappe/email/test_smtp.py b/frappe/email/test_smtp.py index b101f610a1..0495fd8596 100644 --- a/frappe/email/test_smtp.py +++ b/frappe/email/test_smtp.py @@ -73,7 +73,7 @@ def create_email_account(email_id, password, enable_outgoing, default_outgoing=0 "enable_incoming": 1, "append_to": append_to, "is_dummy_password": 1, - "smtp_server": "localhost", + "smtp_server": "127.0.0.1", "use_imap": 0, } diff --git a/frappe/printing/doctype/network_printer_settings/network_printer_settings.py b/frappe/printing/doctype/network_printer_settings/network_printer_settings.py index 7bae0996eb..ea359820d2 100644 --- a/frappe/printing/doctype/network_printer_settings/network_printer_settings.py +++ b/frappe/printing/doctype/network_printer_settings/network_printer_settings.py @@ -20,7 +20,7 @@ class NetworkPrinterSettings(Document): server_ip: DF.Data # end: auto-generated types @frappe.whitelist() - def get_printers_list(self, ip="localhost", port=631): + def get_printers_list(self, ip="127.0.0.1", port=631): printer_list = [] try: import cups diff --git a/frappe/tests/test_db.py b/frappe/tests/test_db.py index 33927b2002..3acb6e99f3 100644 --- a/frappe/tests/test_db.py +++ b/frappe/tests/test_db.py @@ -936,7 +936,7 @@ class TestTransactionManagement(FrappeTestCase): # Treat same DB as replica for tests, a separate connection will be opened class TestReplicaConnections(FrappeTestCase): def test_switching_to_replica(self): - with patch.dict(frappe.local.conf, {"read_from_replica": 1, "replica_host": "localhost"}): + with patch.dict(frappe.local.conf, {"read_from_replica": 1, "replica_host": "127.0.0.1"}): def db_id(): return id(frappe.local.db) diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index 3c5eb48787..91cae01111 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -31,7 +31,7 @@ class BackupGenerator: """ This class contains methods to perform On Demand Backup - To initialize, specify (db_name, user, password, db_file_name=None, db_host="localhost") + To initialize, specify (db_name, user, password, db_file_name=None, db_host="127.0.0.1") If specifying db_file_name, also append ".sql.gz" """ diff --git a/frappe/utils/connections.py b/frappe/utils/connections.py index 2b965fb604..711c4d71f3 100644 --- a/frappe/utils/connections.py +++ b/frappe/utils/connections.py @@ -28,7 +28,7 @@ def is_open(scheme, hostname, port, timeout=10): def check_database(): config = get_conf() db_type = config.get("db_type", "mariadb") - db_host = config.get("db_host", "localhost") + db_host = config.get("db_host", "127.0.0.1") db_port = config.get("db_port", 3306 if db_type == "mariadb" else 5432) return {db_type: is_open(db_type, db_host, db_port)} diff --git a/frappe/utils/data.py b/frappe/utils/data.py index f7c6bf59de..ee092a6a1f 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -1592,7 +1592,7 @@ def get_url(uri: str | None = None, full_address: bool = False) -> str: host_name = frappe.db.get_single_value("Website Settings", "subdomain") if not host_name: - host_name = "http://localhost" + host_name = "http://127.0.0.1" if host_name and not (host_name.startswith("http://") or host_name.startswith("https://")): host_name = "http://" + host_name