# [[HTTP 404 on Nginx]]
![[HTTP 404 on Nginx.svg]]
*Problem:* You're trying to access a site using [[Nginx]] as a web server and you're getting an HTTP 404.
*Cause:* There's something wrong with your Nginx configuration. But what?
## Ways to troubleshoot
To try to get information about why this is happening, try the following things:
- Try accessing the root of your domain where Nginx is installed: `https://yourdomain.com`. Do you get the default Nginx welcome? If you do, that means the default Nginx HTML is working, at least.
- Double check that you've created an `A` record on your domain's [[DNS]] to point to your web server. It may be that your domain isn't configured to redirect to your virtual machine yet.
- Double check every single line of your Nginx config. This is usually saved in `/etc/nginx/sites-enabled.
- Check the error logs: `/var/log/nginx/error.log`.
- Check that the config is valid: `nginx -t`
## Possible root causes and solutions
### Conflicting server name
If you see `warn` messages in either the error logs or by trying a `nginx -t` like this:
```bash
2024/09/13 20:46:04 [warn] 17325#17325: conflicting server name "domain.com" on 0.0.0.0:80, ignored
2024/09/13 20:46:04 [warn] 17325#17325: conflicting server name "domain.com" on [::]:80, ignored
```
then that means you've declared `server_name` twice in your Nginx server blocks. You may have to look at every single `.conf` file in `/etc/nginx/sites-enabled` to see where you're doing this. Or try a:
```bash
grep -rnw . -e domain.com
```
to highlight where `domain.com` is defined.
To fix this, only declare `domain.com` as `server_name` once. When I ran into this in [[2024-09-13#Setting up YOURLS on Google Cloud Platform GCP]], the issue was that I had somehow ended up with two files in `/etc/nginx/sites-enabled`, the default `default` and my own one, `yourls.conf`. So when I ran [[Installing an SSL certificate on Nginx server with Let's Encrypt and Certbot|certbot]], it automatically added another declaration of the same domain to `default`.
So the solution was:
- `cd /etc/nginx/sites-enabled` and `rm default`. This breaks the symlink.
- Run `certbot --nginx -d domain.com` again and say that I wanted to reinstall the current certificate.
- `systemctl restart nginx`
%%
# Excalidraw Data
## Text Elements
## Drawing
```json
{
"type": "excalidraw",
"version": 2,
"source": "https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/2.1.4",
"elements": [
{
"id": "4y8R7iOA",
"type": "text",
"x": 118.49495565891266,
"y": -333.44393157958984,
"width": 3.8599853515625,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"roundness": null,
"seed": 967149026,
"version": 2,
"versionNonce": 939059582,
"isDeleted": true,
"boundElements": null,
"updated": 1713723615080,
"link": null,
"locked": false,
"text": "",
"rawText": "",
"fontSize": 20,
"fontFamily": 4,
"textAlign": "left",
"verticalAlign": "top",
"containerId": null,
"originalText": "",
"lineHeight": 1.2
}
],
"appState": {
"theme": "dark",
"viewBackgroundColor": "#ffffff",
"currentItemStrokeColor": "#1e1e1e",
"currentItemBackgroundColor": "transparent",
"currentItemFillStyle": "solid",
"currentItemStrokeWidth": 2,
"currentItemStrokeStyle": "solid",
"currentItemRoughness": 1,
"currentItemOpacity": 100,
"currentItemFontFamily": 4,
"currentItemFontSize": 20,
"currentItemTextAlign": "left",
"currentItemStartArrowhead": null,
"currentItemEndArrowhead": "arrow",
"scrollX": 583.2388916015625,
"scrollY": 573.6323852539062,
"zoom": {
"value": 1
},
"currentItemRoundness": "round",
"gridSize": null,
"gridColor": {
"Bold": "#C9C9C9FF",
"Regular": "#EDEDEDFF"
},
"currentStrokeOptions": null,
"previousGridSize": null,
"frameRendering": {
"enabled": true,
"clip": true,
"name": true,
"outline": true
}
},
"files": {}
}
```
%%