You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAMP Pro问题:127.0.0.1返回Error 404但http://localhost可正常访问

Troubleshooting 127.0.0.1 404 Error in MAMP Pro 4.4.1 (macOS High Sierra)

Hey there, let’s dig into why 127.0.0.1 is throwing a 404 while http://localhost works fine in your MAMP Pro setup. Here are the most common fixes to try:

  • Verify Apache’s Listen Configuration
    Open MAMP Pro, go to the Apache tab, and click the httpd.conf button to access the main Apache config file. Look for lines starting with Listen:

    • If you see Listen localhost:80 (or your custom port), that means Apache is only listening for requests to the localhost hostname—not the IP address. Change it to Listen 80 (or your port number) to allow Apache to respond to all interfaces, including 127.0.0.1.
    • Save the file, restart Apache in MAMP Pro, and test 127.0.0.1 again.
  • Check Virtual Host Setup for 127.0.0.1
    MAMP Pro’s virtual hosts might not have an entry for 127.0.0.1, even if localhost is configured:

    1. Go to the Hosts tab in MAMP Pro.
    2. If there’s no entry for 127.0.0.1, click the + button to add a new host.
    3. Set the Hostname to 127.0.0.1, point the Document Root to the same directory as your localhost site, and make sure the Status is set to "On".
    4. Save changes and restart Apache.
  • Confirm /etc/hosts File Mapping
    While localhost works, double-check that your system’s hosts file maps 127.0.0.1 correctly:

    1. Open Terminal and run sudo nano /etc/hosts.
    2. Look for a line like 127.0.0.1 localhost—this should be present (and not commented out with a #).
    3. If you want to explicitly map 127.0.0.1 to itself, you can add 127.0.0.1 127.0.0.1 below that line.
    4. Save the file (Ctrl+O, then Enter) and exit (Ctrl+X).
  • Check Apache Error Logs for Clues
    The error logs will tell you exactly why the 404 is happening:

    1. In MAMP Pro’s Apache tab, click the Logs button and select error_log.
    2. Look for recent entries that mention 127.0.0.1—you’ll see details like "File does not exist: /path/to/expected/file" or permission issues.
    3. Fix the root cause (e.g., ensure the document root has an index file like index.php or index.html, or adjust folder permissions).
  • Verify Document Root Permissions
    Make sure the folder you’re using as the document root for 127.0.0.1 has the right permissions:

    • Right-click the folder in Finder, select Get Info, and under Sharing & Permissions, ensure your user account has "Read & Write" access.
    • You can also run sudo chmod -R 755 /path/to/your/document/root in Terminal to set standard permissions.

内容的提问来源于stack exchange,提问作者LaGriffeDigitale

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:25:22